diff --git a/applet.cpp b/applet.cpp index 37c41a6ff..bf7617932 100644 --- a/applet.cpp +++ b/applet.cpp @@ -313,6 +313,12 @@ void Applet::Private::appletAnimationComplete(QGraphicsItem *item, Plasma::Anima if (anim != Animator::DisappearAnimation || item != q) { return; //it's not our time yet } + + cleanUpAndDelete(); +} + +void Applet::Private::cleanUpAndDelete() +{ //kDebug() << "???????????????? DESTROYING APPLET" << name() << " ???????????????????????????"; QGraphicsWidget *parent = dynamic_cast(q->parentItem()); //it probably won't matter, but right now if there are applethandles, *they* are the parent. @@ -334,7 +340,6 @@ void Applet::Private::appletAnimationComplete(QGraphicsItem *item, Plasma::Anima } q->scene()->removeItem(q); - q->deleteLater(); } diff --git a/applet_p.h b/applet_p.h index 121c9b6cc..fae0fa807 100644 --- a/applet_p.h +++ b/applet_p.h @@ -63,6 +63,7 @@ public: void resetConfigurationObject(); void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim); void setFocus(); + void cleanUpAndDelete(); static uint s_maxAppletId; static uint s_maxZValue; diff --git a/containment.cpp b/containment.cpp index 2ca2779e3..b5e83f048 100644 --- a/containment.cpp +++ b/containment.cpp @@ -488,7 +488,10 @@ void Containment::addSiblingContainment() void Containment::clearApplets() { - qDeleteAll(d->applets); + foreach (Applet *applet, d->applets) { + applet->d->cleanUpAndDelete(); + } + d->applets.clear(); } @@ -986,6 +989,7 @@ void Containment::destroy() if (immutability() != Mutable) { return; } + if (isContainment()) { //FIXME maybe that %1 should be the containment type not the name if (KMessageBox::warningContinueCancel(0, i18n("Do you really want to remove this %1?", name()), diff --git a/corona.cpp b/corona.cpp index ffabfa715..d5e3fcafc 100644 --- a/corona.cpp +++ b/corona.cpp @@ -337,6 +337,7 @@ void Corona::destroyContainment(Containment *c) if (!d->containments.contains(c)) { return; } + //don't remove a desktop that's in use //FIXME allow removal of containments for screens that don't currently exist if (c->containmentType() != Containment::PanelContainment && c->screen() != -1) { @@ -344,6 +345,7 @@ void Corona::destroyContainment(Containment *c) } d->containments.removeAll(c); + removeItem(c); c->config().deleteGroup(); c->deleteLater(); }