diff --git a/applet.cpp b/applet.cpp index 421de4991..b776f7a4d 100644 --- a/applet.cpp +++ b/applet.cpp @@ -256,6 +256,14 @@ KConfigGroup Applet::globalConfig() const void Applet::destroy() { //kDebug() << "???????????????? DESTROYING APPLET" << name() << " ???????????????????????????"; + QGraphicsWidget * item = dynamic_cast(parentItem()); + //is the applet in a containment and is the containment have a layout? if yes, we remove the applet in the layout + if (item) { + QGraphicsLinearLayout * lay = dynamic_cast(item->layout()); + if (lay) { + lay->removeItem(this); + } + } if (d->configXml) { d->configXml->setDefaults(); } diff --git a/containment.cpp b/containment.cpp index fb2ab4fc1..d94316ba2 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1024,15 +1024,7 @@ void Containment::Private::appletAnimationComplete(QGraphicsItem *item, Plasma:: while (parent) { if (parent == q) { Applet *applet = qgraphicsitem_cast(item); - - if (applet) { - QGraphicsLinearLayout * lay = dynamic_cast(q->layout()); - if (lay) { - lay->removeItem(applet); - } - applet->destroy(); - } - + applet->destroy(); break; }