From 1387b5efe31e330777c8ffd9029f79063cc7a7a9 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 13 Apr 2017 10:41:40 +0100 Subject: [PATCH] Guard against Applet not loading AppletInterface Summary: This can happen if an applet has invalid metadata, it doesn't have a script engine set (X-Plasma-API) so it won't load the DeclarativeAppletScripts Having invalid metadata could come from the applet, or from the fallback applet created in Containment::Private::createApplet. We guard against it in appletAdded but not in appletRemoved, which is inconsistent. We also apparently must have guards elsewhere otherwise we'd see the crash more. BUG: 377050 Test Plan: Had corrupt applet, used to crash, now doesn't Reviewers: #plasma Subscribers: plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D5423 --- src/scriptengines/qml/plasmoid/containmentinterface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 2ba4a8218..e311f6018 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -821,7 +821,8 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) // qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject // << "Applet: " << applet << applet->title() << appletGraphicObject; - //Every applet should have a graphics object, otherwise don't disaplay anything + //applets can not have a graphic object if they don't have a script engine loaded + //this can happen if they were loaded with an invalid metadata if (!appletGraphicObject) { return; } @@ -843,8 +844,10 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) { AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value(); - m_appletInterfaces.removeAll(appletGraphicObject); - appletGraphicObject->m_positionBeforeRemoval = appletGraphicObject->mapToItem(this, QPointF()); + if (appletGraphicObject) { + m_appletInterfaces.removeAll(appletGraphicObject); + appletGraphicObject->m_positionBeforeRemoval = appletGraphicObject->mapToItem(this, QPointF()); + } emit appletRemoved(appletGraphicObject); emit appletsChanged(); }