Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] o woe is me

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Juan Carlos Torres <carlosdgtorres AT gmail.com>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] o woe is me
  • Date: Thu, 10 Apr 2008 22:44:58 +0800

Forwarding a patch for kdelibs4 found by Juuso in KDE trunk. This patch is
already in trunk and will probably be included in the next snapshot
(4.0.69?).

Note: use -p1

I'm attaching the PRE_BUILD script I used to test this patch. Not sure if I
did it correctly, since I just used scribbler to copy kdelibs4 and added
PRE_BUILD. :)


--
Juan Carlos G. Torres
Jucato
1024D/6F507597
--- Begin Message ---
  • From: Juuso Alasuutari <juuso.alasuutari AT gmail.com>
  • To: carlosdgtorres AT gmail.com
  • Subject: kdelibs-4.0.68 patch
  • Date: Thu, 10 Apr 2008 14:34:19 +0300
Here you go. Apply with -p1.

Juuso
--- kdelibs-4.0.68/kdecore/kernel/kglobal.cpp	2008/04/02 09:10:19	792807
+++ kdelibs-4.0.68/kdecore/kernel/kglobal.cpp	2008/04/04 08:28:47	793497
@@ -46,6 +46,7 @@
 #include <QtCore/QCoreApplication>
 #include <QtCore/QTextCodec>
 #include "kcmdlineargs.h"
+#include <unistd.h> // umask
 
 #ifndef NDEBUG
 #define MYASSERT(x) if (!x) \
@@ -61,6 +62,7 @@
 Q_CONSTRUCTOR_FUNCTION(qrand)
 
 typedef QSet<QString> KStringDict;
+mode_t s_umsk;
 
 class KGlobalPrivate
 {
@@ -72,8 +74,8 @@
         {
             // the umask is read here before any threads are created to avoid race conditions
             mode_t tmp = 0;
-            umsk = umask(tmp);
-            umask(umsk);
+            s_umsk = umask(tmp);
+            umask(s_umsk);
         }
 
         inline ~KGlobalPrivate()
@@ -91,7 +93,6 @@
         KStringDict *stringDict;
         KLocale *locale;
         KCharsets *charsets;
-        mode_t umsk;
 };
 
 K_GLOBAL_STATIC(KGlobalPrivate, globalData)
@@ -164,8 +165,8 @@
 
 mode_t KGlobal::umask()
 {
-    PRIVATE_DATA;
-    return d->umsk;
+    // Don't use PRIVATE_DATA here. This is called by ~KGlobalPrivate -> ~KConfig -> sync -> KSaveFile, so there's no KGlobalPrivate anymore.
+    return s_umsk;
 }
 
 KComponentData KGlobal::activeComponent()
--- kdelibs-4.0.68/kdecore/tests/kconfigtest.cpp	2008/04/04 08:26:12	793496
+++ kdelibs-4.0.68/kdecore/tests/kconfigtest.cpp	2008/04/04 08:28:47	793497
@@ -1021,3 +1021,12 @@
     QVERIFY(QFile::exists(file));
 }
 
+void KConfigTest::testSyncOnExit()
+{
+    // Often, the KGlobalPrivate global static's destructor ends up calling ~KConfig ->
+    // KConfig::sync ... and if that code triggers KGlobal code again then things could crash.
+    // So here's a test for modifying KGlobal::config() and not syncing, the process exit will sync.
+    KConfigGroup grp(KGlobal::config(), "syncOnExit");
+    grp.writeEntry("key", "value");
+}
+
--- kdelibs-4.0.68/kdecore/tests/kconfigtest.h	2008/04/04 08:26:12	793496
+++ kdelibs-4.0.68/kdecore/tests/kconfigtest.h	2008/04/04 08:28:47	793497
@@ -64,6 +64,9 @@
 
     // unrelated
     void testKAboutDataOrganizationDomain();
+
+    // should be last
+    void testSyncOnExit();
 private:
     void revertEntries();
     QList<QByteArray> readLines();

--- End Message ---
default_pre_build &&
cd $SOURCE_DIRECTORY &&

# apply patch to fix logging in using kdm4
patch -p1 < $SPELL_DIRECTORY/kdelibs-4.0.68.patch



Archive powered by MHonArc 2.6.24.

Top of Page