a couple of related fixes to make destroying containments work a lot better

svn path=/trunk/KDE/kdelibs/; revision=889816
This commit is contained in:
Aaron J. Seigo 2008-11-27 18:55:32 +00:00
parent 4d962352a9
commit 509632ff64
3 changed files with 14 additions and 9 deletions

View File

@ -133,7 +133,9 @@ Applet::Applet(QObject *parentObject, const QVariantList &args)
Applet::~Applet() Applet::~Applet()
{ {
if (d->extender) { if (d->transient) {
d->resetConfigurationObject();
} else if (d->extender) {
//This would probably be nicer if it was located in extender. But in it's dtor, this won't //This would probably be nicer if it was located in extender. But in it's dtor, this won't
//work since when that get's called, the applet's config() isn't accessible anymore. (same //work since when that get's called, the applet's config() isn't accessible anymore. (same
//problem with calling saveState(). Doing this in saveState() might be a possibility, but //problem with calling saveState(). Doing this in saveState() might be a possibility, but
@ -150,10 +152,6 @@ Applet::~Applet()
d->extender->saveState(); d->extender->saveState();
} }
if (d->transient) {
d->resetConfigurationObject();
}
delete d; delete d;
} }
@ -2032,9 +2030,11 @@ void AppletPrivate::themeChanged()
void AppletPrivate::resetConfigurationObject() void AppletPrivate::resetConfigurationObject()
{ {
mainConfigGroup()->deleteGroup(); if (mainConfig) {
delete mainConfig; mainConfig->deleteGroup();
mainConfig = 0; delete mainConfig;
mainConfig = 0;
}
} }
uint AppletPrivate::s_maxAppletId = 0; uint AppletPrivate::s_maxAppletId = 0;

View File

@ -111,6 +111,11 @@ Containment::Containment(QObject *parent, const QVariantList &args)
Containment::~Containment() Containment::~Containment()
{ {
if (Applet::d->transient) {
Applet::d->resetConfigurationObject();
Applet::d->transient = false;
}
delete d; delete d;
} }

View File

@ -272,7 +272,7 @@ Containment *View::swapContainment(Plasma::Containment *existing, const QString
oldConfig.copyTo(&newConfig); oldConfig.copyTo(&newConfig);
if (old == d->containment) { if (old == d->containment) {
// set our containment to the new one // set our containment to the new one, if the the old containment was us
setContainment(c); setContainment(c);
} }