--- branches/KDE/4.0/kdelibs/kdecore/kernel/kglobal.cpp 2008/01/04 09:09:11 757128
+++ branches/KDE/4.0/kdelibs/kdecore/kernel/kglobal.cpp 2008/04/04 08:48:53 793504
@@ -28,6 +28,12 @@
#include "kglobal.h"
#include "kglobal_p.h"
+#include <config.h>
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
#include <QtCore/QList>
#include <QtCore/QSet>
@@ -40,6 +46,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QTextCodec>
#include "kcmdlineargs.h"
+#include <unistd.h> // umask
#ifndef NDEBUG
#define MYASSERT(x) if (!x) \
@@ -55,6 +62,7 @@
Q_CONSTRUCTOR_FUNCTION(qrand)
typedef QSet<QString> KStringDict;
+mode_t s_umsk;
class KGlobalPrivate
{
@@ -64,6 +72,10 @@
locale(0),
charsets(0)
{
+ // the umask is read here before any threads are created to avoid race conditions
+ mode_t tmp = 0;
+ s_umsk = umask(tmp);
+ umask(s_umsk);
}
inline ~KGlobalPrivate()
@@ -151,6 +163,12 @@
return d->charsets;
}
+mode_t KGlobal::umask()
+{
+ // 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()
{
PRIVATE_DATA;