OSDN Git Service

fix data race on isDebugging bool
authorIvailo Monev <xakepa10@gmail.com>
Tue, 26 Jan 2016 13:16:40 +0000 (15:16 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 26 Jan 2016 13:16:40 +0000 (15:16 +0200)
also fixed warning about undefined QDBUS_THREAD_DEBUG

upstream commits:
https://github.com/qtproject/qtbase/commit/7a4dcbaabf037a6913a5662ebb74cc47e04673b9

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/dbus/qdbusintegrator.cpp
src/dbus/qdbusthreaddebug_p.h

index b45d02f..c598004 100644 (file)
@@ -70,8 +70,8 @@
 
 QT_BEGIN_NAMESPACE
 
-static bool isDebugging;
-#define qDBusDebug              if (!::isDebugging); else qDebug
+static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
+#define qDBusDebug              if (::isDebugging == 0); else qDebug
 
 Q_GLOBAL_STATIC_WITH_ARGS(const QString, orgFreedesktopDBusString, (QLatin1String(DBUS_SERVICE_DBUS)))
 
@@ -981,13 +981,12 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
       rootNode(QString(QLatin1Char('/')))
 {
     static const bool threads = q_dbus_threads_init_default();
-    static const int debugging = qgetenv("QDBUS_DEBUG").toInt();
-    ::isDebugging = debugging;
+    if (::isDebugging == -1)
+        ::isDebugging = qgetenv("QDBUS_DEBUG").toInt();
     Q_UNUSED(threads)
-    Q_UNUSED(debugging)
 
-#ifdef QDBUS_THREAD_DEBUG
-    if (debugging > 1)
+#if QDBUS_THREAD_DEBUG
+    if (::isDebugging > 1)
         qdbusThreadDebug = qdbusDefaultThreadDebug;
 #endif
 
index b1a3707..a436e04 100644 (file)
@@ -58,6 +58,8 @@
 
 #if !defined(QDBUS_THREAD_DEBUG) && defined(QT_BUILD_INTERNAL)
 # define QDBUS_THREAD_DEBUG 1
+#else
+# define QDBUS_THREAD_DEBUG 0
 #endif
 
 #if QDBUS_THREAD_DEBUG