From 509632ff648e9c759daf3a1ed0a3df32f5a58f7e Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 27 Nov 2008 18:55:32 +0000 Subject: [PATCH] a couple of related fixes to make destroying containments work a lot better svn path=/trunk/KDE/kdelibs/; revision=889816 --- applet.cpp | 16 ++++++++-------- containment.cpp | 5 +++++ view.cpp | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/applet.cpp b/applet.cpp index 7e01626b8..64ba5de80 100644 --- a/applet.cpp +++ b/applet.cpp @@ -133,7 +133,9 @@ Applet::Applet(QObject *parentObject, const QVariantList &args) 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 //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 @@ -150,10 +152,6 @@ Applet::~Applet() d->extender->saveState(); } - if (d->transient) { - d->resetConfigurationObject(); - } - delete d; } @@ -2032,9 +2030,11 @@ void AppletPrivate::themeChanged() void AppletPrivate::resetConfigurationObject() { - mainConfigGroup()->deleteGroup(); - delete mainConfig; - mainConfig = 0; + if (mainConfig) { + mainConfig->deleteGroup(); + delete mainConfig; + mainConfig = 0; + } } uint AppletPrivate::s_maxAppletId = 0; diff --git a/containment.cpp b/containment.cpp index 274d6a4a7..a37843aba 100644 --- a/containment.cpp +++ b/containment.cpp @@ -111,6 +111,11 @@ Containment::Containment(QObject *parent, const QVariantList &args) Containment::~Containment() { + if (Applet::d->transient) { + Applet::d->resetConfigurationObject(); + Applet::d->transient = false; + } + delete d; } diff --git a/view.cpp b/view.cpp index d1b625577..029251a12 100644 --- a/view.cpp +++ b/view.cpp @@ -272,7 +272,7 @@ Containment *View::swapContainment(Plasma::Containment *existing, const QString oldConfig.copyTo(&newConfig); 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); }