In Amarok trunk, we have been experencing a crash-on-exit issue for a long time (also see BUG 187384). Unfortunately it's rather hard to reproduce (happens like 1 out of 10 times), but some research has shown that the culprit is this: Sometimes this call just returns an empty QStringList: "Plasma::DataEngineManager::self()->listAllEngines( "Amarok" )" Following this, Amarok crashes on exit, as it does not unload its Plasma engines. I have added an assert in Amarok to trace this down, and it does indicate a bug in libPlasma, I think (don't have any other explanation). Here's some debug output: amarok: BEGIN: virtual Context::ContextView::~ContextView() ASSERT failure in Listing loaded Plasma engines: "List is empty (no engines loaded!?)", file /home/mark/kde/src/amarok/src/context/ContextView.cpp, line 98
Using KDE 4.2.1, forgot to mention this.
listAllEngines just does a KServiceTypeTrader call: KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint); if there's an error (versus just an empty set returned) you should get some debut output to that effect on console as well. it might be interesting to see what's up in KServiceTypeTrader there; however, it would seem to me to make more sense to do something like what Plasma::Applet does and keep track of the DataEngines loaded by your objects and unload them when they exit. that way you don't even need the list afterwards. looking at the code, however, this all seems a bit superfluous. the dataEngine is ref'd when an applet loads it, and unrefed when the applet is done with it (e.g. when it is deleted). so perhaps the real issue here is that applets aren't getting deleted on exit?
Ok, considering what you wrote, I find it now less likely that this is a bug in libPlasma. My new theory is that this only affects specific setups, where Amarok is installed in such a way that ksycoca sometimes does not work reliably. But please let me keep this report open a for a while, until I can be more certain about my suspicions. Will take care of closing it then, or otherwise report my findings.
i don't see why you should be needing to delete the engines in this manner in the first place? the applets accessing them via dataEngine will have them automatically deleted for them when they are deleted (and thus the usage count on the engine drops to zero), so just make sure to delete all the applets on exit for that. if other things are using engines, they should similarly keep track of it. but looking at the amarok sources, it's just applets that are using the dataengines, so it seems to me that either the applets aren't being deleted at close or else the reference counting isn't working as expected.
Ooook, after some days of thinking and experimenting I can say with some confidence: This is _not_ a bug in Plasma :) The real problem outlined in short: Some people had set $KDEDIR in .bashrc, which ksycoca does not pick up reliably. Moving this to $HOME/.kde/env/myenv.sh fixes the problem (although this solution is not all that obvious;) I've blogged an updated guide for installing Amarok here: http://amarok.kde.org/blog/archives/989-Building-Amarok-SVN-in-HOME-An-Update.html Cheers guys (hey, let's go clubbing some time again!)