diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-08-29 18:12:28 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-08 01:44:13 +0200 |
commit | 194e0bd7e47a9e7a73597c218ffc3f04a50e8e48 (patch) | |
tree | 4af75ba4081a6431a8e935776d930b69222ac509 /src/dbus | |
parent | 4f4fc20d2d0188978c43e105ed60d71ba2396fd4 (diff) |
QDBusIntegrator: fix unprotected QDBusPendingCallPrivate::waitingForFinished call
There probably is a happens-before relation to all the writes of the bool elsewhere,
but the comment in QDBusPendingCallPrivate says waitingForFinsihed is one of the
variables protected by the mutex, so don't make every reader of the code re-establish
the safety (if indeed, it is safe) oneself again, but just wrap the access in a
mutex lock.
To be able to compile the mutex locking out of release builds, wrap the access
in a function. Make the function static _inline_ so compilers won't complain
about it being unused in release builds.
Change-Id: I914ce91e64e776450c697a3243b35716390a218c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 231e973106..eada7b7792 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1779,6 +1779,12 @@ void QDBusConnectionPrivate::waitForFinished(QDBusPendingCallPrivate *pcall) } } +static inline bool waitingForFinishedIsSet(QDBusPendingCallPrivate *call) +{ + const QMutexLocker locker(&call->mutex); + return call->waitingForFinished; +} + void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call) { QDBusConnectionPrivate *connection = const_cast<QDBusConnectionPrivate *>(call->connection); @@ -1828,7 +1834,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call) emit connection->callWithCallbackFailed(QDBusError(msg), call->sentMessage); if (call->autoDelete) { - Q_ASSERT(!call->waitingForFinished); // can't wait on a call with autoDelete! + Q_ASSERT(!waitingForFinishedIsSet(call)); // can't wait on a call with autoDelete! delete call; } } |