[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: kdelibs/kdecore
From:       Waldo Bastian <bastian () kde ! org>
Date:       2003-09-24 13:15:00
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 23 September 2003 17:50, Zack Rusin wrote:
> On Tuesday 23 September 2003 05:19, Waldo Bastian wrote:
> > Indeed, thanks for the detailed report. It should be fixed now.
> >
> > When debugging I discovered that KMail uses two KConfig objects that
> > both operate on kmailrc. It would be more efficient if you could
> > manage to share a single configuration object. I assume that Kmail
> > uses two because one is used for the part and one is used for the
> > shell?
>
> If it has two then that's a bug. The only KConfig object that should
> operate on kmailrc is KMKernel::config() and that's the one it should
> always be used.

It uses two because KApplication creates one too.

The attached patch fixes KMail using the new KSharedConfig class. I had to do 
a little reworking: I store the config object with a refcounted 
KSharedConfig::Ptr in KMKernel, when KMKernel gets destructed the ptr gets 
derefed. In KMail the KApplication object (KInstance) will hold another 
reference. When KMKernel and KApplication have been destructed both the 
KConfig object will be deleted.

PS: In the "You forgot the attachment"-dialog the cursor remains a busy 
cursor.

Cheers,
Waldo
- -- 
bastian@kde.org -=|[ SuSE, The Linux Desktop Experts ]|=- bastian@suse.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/cZjYN4pvrENfboIRAtoLAKCND6KgLdw1L6kFzqwaIIBK+RWCEwCfSxWE
uYewUub/tP4jBPsBDWGEwig=
=wOSC
-----END PGP SIGNATURE-----

["kmail_config.patch" (text/x-diff)]

Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.cpp,v
retrieving revision 1.202
diff -u -r1.202 kmkernel.cpp
--- kmkernel.cpp	21 Sep 2003 04:39:36 -0000	1.202
+++ kmkernel.cpp	24 Sep 2003 12:55:22 -0000
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "kmkernel.h"
 
+#include "kmstartup.h"
 #include "kmmsgindex.h"
 #include "kmmainwin.h"
 #include "kmcomposewin.h"
@@ -1438,14 +1439,16 @@
   }
 }
 
-KConfig *KMKernel::myConfig = 0;
-static KStaticDeleter<KConfig> myConfigSD;
-
 KConfig* KMKernel::config()
 {
-    if (!myConfig)
-	myConfig = myConfigSD.setObject(myConfig, new KConfig( "kmailrc"));
-    return myConfig;
+    assert(mySelf);
+    if (!mySelf->mConfig)
+    {
+	mySelf->mConfig = KSharedConfig::openConfig( "kmailrc" );
+        // Check that all updates have been run on the config file:
+        KMail::checkConfigUpdates();
+    }
+    return mySelf->mConfig;
 }
 
 KMGroupware & KMKernel::groupware()
Index: kmkernel.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.h,v
retrieving revision 1.76
diff -u -r1.76 kmkernel.h
--- kmkernel.h	20 Sep 2003 16:09:15 -0000	1.76
+++ kmkernel.h	24 Sep 2003 12:55:23 -0000
@@ -6,6 +6,8 @@
 #include <qobject.h>
 #include <qstring.h>
 
+#include <kconfig.h>
+
 #include "kmailIface.h"
 
 #define kmkernel KMKernel::self()
@@ -20,7 +22,6 @@
 }
 using KMail::MailServiceImpl;
 using KMail::UndoStack;
-class KConfig;
 class KMMsgIndex;
 class QLabel;
 class KMFolder;
@@ -269,7 +270,7 @@
   bool allowedToExpire;
   bool the_firstInstance;
   static KMKernel *mySelf;
-  static KConfig *myConfig;
+  KSharedConfig::Ptr mConfig;
   QTextCodec *netCodec;
   KProgress *mProgress;
   KPassivePopup *mCleanupPopup;
Index: main.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/main.cpp,v
retrieving revision 1.185
diff -u -r1.185 main.cpp
--- main.cpp	20 Sep 2003 16:09:19 -0000	1.185
+++ main.cpp	24 Sep 2003 12:55:23 -0000
@@ -169,9 +169,6 @@
   // import i18n data from libraries:
   KMail::insertLibraryCatalogues();
 
-  // Check that all updates have been run on the config file:
-  KMail::checkConfigUpdates();
-
   // Make sure that the KNotify Daemon is running (this is necessary for people
   // using KMail without KDE)
   KNotifyClient::startDaemon();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic