Fix crash when uridecodebin fails. (#6077)

Let's the user see the error message what failed instead of Clementine crashing.

Also don't do gst_object_unref unless bin is set.
This fixes GStreamer-CRITICAL gst_object_unref: assertion 'object != NULL' failed
This commit is contained in:
Jonas Kvinge 2018-06-07 00:53:25 +02:00 committed by John Maguire
parent 6f3032a1ec
commit 925e74f909
2 changed files with 4 additions and 2 deletions

View File

@ -759,7 +759,7 @@ GstElement* GstEngine::CreateElement(const QString& factoryName,
"GStreamer could not create the element: %1. "
"Please make sure that you have installed all necessary "
"GStreamer plugins (e.g. OGG and MP3)").arg(factoryName));
gst_object_unref(GST_OBJECT(bin));
if (bin) gst_object_unref(GST_OBJECT(bin));
return nullptr;
}

View File

@ -157,8 +157,9 @@ bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
// Create elements
GstElement* src = engine_->CreateElement("tcpserversrc", new_bin);
if (!src) return false;
GstElement* gdp = engine_->CreateElement("gdpdepay", new_bin);
if (!src || !gdp) return false;
if (!gdp) return false;
// Pick a port number
const int port = Utilities::PickUnusedPort();
@ -182,6 +183,7 @@ bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
Q_ARG(QString, url.toString()), Q_ARG(quint16, port));
} else {
new_bin = engine_->CreateElement("uridecodebin");
if (!new_bin) return false;
g_object_set(G_OBJECT(new_bin), "uri", url.toEncoded().constData(),
nullptr);
CHECKED_GCONNECT(G_OBJECT(new_bin), "drained", &SourceDrainedCallback,