Merge pull request #4565 from Phasip/master

Fix moodbar segfault when playing broken mp3
This commit is contained in:
ArnaudBienner 2014-10-06 22:23:23 +02:00
commit 3de86b902e
2 changed files with 10 additions and 6 deletions

View File

@ -158,13 +158,15 @@ void MoodbarBuilder::Normalize(QList<Rgb>* vals, double Rgb::*member) {
}
QByteArray MoodbarBuilder::Finish(int width) {
Normalize(&frames_, &Rgb::r);
Normalize(&frames_, &Rgb::g);
Normalize(&frames_, &Rgb::b);
QByteArray ret;
ret.resize(width * 3);
char* data = ret.data();
if (frames_.count() == 0)
return ret;
Normalize(&frames_, &Rgb::r);
Normalize(&frames_, &Rgb::g);
Normalize(&frames_, &Rgb::b);
for (int i = 0; i < width; ++i) {
Rgb rgb;

View File

@ -181,8 +181,10 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus*, GstMessage* msg,
void MoodbarPipeline::Stop(bool success) {
success_ = success;
data_ = builder_->Finish(1000);
builder_.reset();
if (builder_ != nullptr) {
data_ = builder_->Finish(1000);
builder_.reset();
}
emit Finished(success);
}