KStaticDeleter, KLibLoader and missing KApplication

Matthias Kretz kretz at kde.org
Mon Jan 8 16:49:16 GMT 2007


Hi,

nowadays KDE is supposed to work without KApplication, but ~KApplication() did 
some important cleanups... Here's a suggestion to fix it, but I'm not sure 
it's the 100% solution as the postRoutine is only installed if a 
KStaticDeleter is used. In the (rare) case that no KStaticDeleter is used 
KLibLoader::cleanUp() is not called on ~QCoreApplication(). Dunno whether 
that's necessary, though.

Please review:

Index: kdecore/kernel/kglobal.cpp
===================================================================
--- kdecore/kernel/kglobal.cpp  (revision 620590)
+++ kdecore/kernel/kglobal.cpp  (working copy)
@@ -37,6 +37,7 @@
 #include <kstandarddirs.h>
 #include <kinstance.h>
 #include <qcoreapplication.h>
+#include <klibloader.h>
 #include "kstaticdeleter.h"

 #ifndef NDEBUG
@@ -249,12 +250,23 @@
     KGlobal::setActiveInstance(0);
 }

+static void kglobal_postRoutine()
+{
+    // First call the static deleters and then call KLibLoader::cleanup()
+    // The static deleters may delete libraries for which they need 
KLibLoader.
+    // KLibLoader will take care of the remaining ones.
+    KGlobal::deleteStaticDeleters();
+    KLibLoader::cleanUp();
+}
+
 static void kglobal_init()
 {
     if (KGlobal::_staticDeleters)
         return;

     KGlobal::_staticDeleters = new KStaticDeleterList;
+
+    qAddPostRoutine(kglobal_postRoutine);
 }


Index: kdeui/kernel/kapplication.cpp
===================================================================
--- kdeui/kernel/kapplication.cpp       (revision 620590)
+++ kdeui/kernel/kapplication.cpp       (working copy)
@@ -840,12 +840,6 @@

 KApplication::~KApplication()
 {
-  // First call the static deleters and then call KLibLoader::cleanup()
-  // The static deleters may delete libraries for which they need KLibLoader.
-  // KLibLoader will take care of the remaining ones.
-  KGlobal::deleteStaticDeleters();
-  KLibLoader::cleanUp();
-
 #ifdef Q_WS_X11
   if ( d->oldXErrorHandler != NULL )
       XSetErrorHandler( d->oldXErrorHandler );

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070108/9864a96f/attachment.sig>


More information about the kde-core-devel mailing list