Don't crash if the plasmoid wasn't properly loaded

If d->applet->package().isValid(), then d->qmlObject->mainComponent()
is null.
This makes Plasma crash when a faulty plasmoid is loaded.

REVIEW: 120581
This commit is contained in:
Aleix Pol 2014-10-14 15:44:33 +02:00
parent 71444986ee
commit 8df7801d3b

View File

@ -437,7 +437,7 @@ void AppletQuickItem::init()
d->qmlObject->setSource(QUrl::fromLocalFile(d->applet->package().filePath("mainscript")));
if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || d->qmlObject->mainComponent()->isError()) {
if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || !d->qmlObject->mainComponent() || d->qmlObject->mainComponent()->isError()) {
QString reason;
if (d->applet->package().isValid()) {
foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) {