diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 8546a6533..55145e69c 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -562,7 +562,7 @@ Types::FormFactor Applet::formFactor() const Containment *Applet::containment() const { Containment *c = qobject_cast(const_cast(this)); - if (c) { + if (c && qobject_cast(parent())) { return c; } @@ -577,20 +577,6 @@ Containment *Applet::containment() const parent = parent->parent(); } - if (!c) { - //if the applet is an offscreen widget its parentItem will be 0, while its parent - //will be its parentWidget, so here we check the QObject hierarchy. - QObject *objParent = this->parent(); - while (objParent) { - Containment *possibleC = qobject_cast(objParent); - if (possibleC) { - c = possibleC; - break; - } - objParent = objParent->parent(); - } - } - return c; } @@ -757,7 +743,7 @@ void Applet::timerEvent(QTimerEvent *event) bool Applet::isContainment() const { - return qobject_cast(this); + return qobject_cast(this) && qobject_cast(parent()); } } // Plasma namespace