safety in removing panels, aka "work around the inane requirement to first remove items from the scene before deleting them if they are a QGraphicsWidget and have a layout"

BUG:163205

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=816760
This commit is contained in:
Aaron J. Seigo 2008-06-04 19:04:34 +00:00
parent 1cb044332c
commit f1ce0ee124
4 changed files with 14 additions and 2 deletions

View File

@ -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<QGraphicsWidget *>(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();
}

View File

@ -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;

View File

@ -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()),

View File

@ -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();
}