From 9983bde0889715fcaeebb05d26d02ed3a66affcd Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 26 Jan 2016 15:16:40 +0200 Subject: [PATCH] fix data race on isDebugging bool also fixed warning about undefined QDBUS_THREAD_DEBUG upstream commits: https://github.com/qtproject/qtbase/commit/7a4dcbaabf037a6913a5662ebb74cc47e04673b9 Signed-off-by: Ivailo Monev --- src/dbus/qdbusintegrator.cpp | 13 ++++++------- src/dbus/qdbusthreaddebug_p.h | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index b45d02fb5..c59800416 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -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 diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h index b1a370778..a436e045a 100644 --- a/src/dbus/qdbusthreaddebug_p.h +++ b/src/dbus/qdbusthreaddebug_p.h @@ -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 -- 2.11.0