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