On Wednesday 10 June 2009, Petri Damstén wrote:
> Seems that this is because mainConfig is created without containment:
> plasma-desktop(1574)/libplasma Plasma::AppletPrivate::mainConfigGroup:
> requesting config for "Now Rocking" without a containment!

which probably means that config() is being called during the applet ctor 
somewhere. this is obviously wrong an it would be good to track down where 
this is happening, e.g. by running now rocking in plasmoidviewer in gdb with a 
breakpoint set on that debug message in Applet::Private::config()

we should still catch such mistakes gracefully, however. does the attached 
patch help?



-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Software

Index: applet.cpp
===================================================================
--- applet.cpp	(revision 979854)
+++ applet.cpp	(working copy)
@@ -1972,6 +1972,23 @@
         }
     }
         break;
+    case ItemParentChange:
+        if (d->mainConfig && !d->isContainment &&
+            !dynamic_cast<Containment*>(parentItem()) &&
+            dynamic_cast<Containment*>(value.value<QGraphicsItem *>())) {
+            // if this is an applet, and we've just been assigned to our first containment,
+            // but the applet did something stupid like ask for the config() object prior to
+            // this happening (e.g. inits ctor) then let's repair that situation for them.
+            kWarning() << "Configuration object was requested prior to init(), which is too early. "
+                          "Please fix this item:" << name();
+            KConfigGroup *old = d->mainConfig;
+            KConfigGroup appletConfig = dynamic_cast<Containment*>(value.value<QGraphicsItem *>())->config();
+            appletConfig = KConfigGroup(&appletConfig, "Applets");
+            d->mainConfig = new KConfigGroup(&appletConfig, QString::number(d->appletId));
+            old->copyTo(d->mainConfig);
+            old->deleteGroup();
+            delete old;
+        }
     case ItemPositionChange:
         return (immutability() == Mutable || isContainment() || formFactor() == Horizontal || formFactor() == Vertical) ? value : pos();
         break;

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to