diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index c049fc32a..81c49c469 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -300,7 +300,17 @@ void Containment::setContainmentType(Plasma::Types::ContainmentType type) Corona *Containment::corona() const { - return qobject_cast(parent()); + if(Plasma::Corona* corona = qobject_cast(parent())) { + return corona; + //case in which this containment is child of an applet, hello systray :) + } else { + Plasma::Applet *parentApplet = qobject_cast(parent()); + if (parentApplet) { + return parentApplet->containment()->corona(); + } + } + + return nullptr; } void Containment::setFormFactor(Types::FormFactor formFactor) @@ -448,16 +458,9 @@ QList Containment::applets() const int Containment::screen() const { - if (corona()) { - return corona()->screenForContainment(this); - - //case in which this containment is child of an applet, hello systray :) - } else if (Plasma::Applet *parentApplet = qobject_cast(parent())) { - if (parentApplet->containment()) { - return parentApplet->containment()->screen(); - } else { - return -1; - } + Q_ASSERT(corona()); + if (Corona* c = corona()) { + return c->screenForContainment(this); } else { return -1; }