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
This commit is contained in:
parent
a01e4fb69e
commit
1387b5efe3
@ -821,7 +821,8 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
|||||||
// qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject
|
// qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject
|
||||||
// << "Applet: " << applet << applet->title() << appletGraphicObject;
|
// << "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) {
|
if (!appletGraphicObject) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -843,8 +844,10 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
|||||||
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
||||||
{
|
{
|
||||||
AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value<AppletInterface *>();
|
AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value<AppletInterface *>();
|
||||||
|
if (appletGraphicObject) {
|
||||||
m_appletInterfaces.removeAll(appletGraphicObject);
|
m_appletInterfaces.removeAll(appletGraphicObject);
|
||||||
appletGraphicObject->m_positionBeforeRemoval = appletGraphicObject->mapToItem(this, QPointF());
|
appletGraphicObject->m_positionBeforeRemoval = appletGraphicObject->mapToItem(this, QPointF());
|
||||||
|
}
|
||||||
emit appletRemoved(appletGraphicObject);
|
emit appletRemoved(appletGraphicObject);
|
||||||
emit appletsChanged();
|
emit appletsChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user