From 7a4dcbaabf037a6913a5662ebb74cc47e04673b9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 8 Jun 2014 15:39:00 +0200 Subject: [PATCH 1/1] QDBus: fix data race on isDebugging bool Change-Id: Id0b8bf8dac570abfc6c8768bd4264650ae0c199b Reviewed-by: Thiago Macieira --- src/dbus/qdbusintegrator.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 1fef6d4..260c188 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -73,8 +73,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))) @@ -1022,13 +1022,12 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) anonymousAuthenticationAllowed(false) { 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 (::isDebugging > 1) qdbusThreadDebug = qdbusDefaultThreadDebug; #endif -- 1.9.3