summaryrefslogtreecommitdiffstats
path: root/src/corelib/arch/qatomic_bootstrap.h
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2014-06-08 21:46:24 +0200
committerThiago Macieira <thiago.macieira@intel.com>2014-06-20 21:54:04 +0200
commit884b38157689a893ace0a4c793fab921167abb2c (patch)
treec0f4a079a79c760ad08506017ed296880f529da1 /src/corelib/arch/qatomic_bootstrap.h
parentd98004cd2f33e8147cff9f3cb203fdef5e6dd00e (diff)
Fix data race on QLoggingCategory when using qDebug from multiple threads
setEnabled() would race with isEnabled()/isDebugEnabled()/etc. Change-Id: I2004cba81d5417a634b97f5c2f98d3a4ab71770d Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/arch/qatomic_bootstrap.h')
-rw-r--r--src/corelib/arch/qatomic_bootstrap.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/arch/qatomic_bootstrap.h b/src/corelib/arch/qatomic_bootstrap.h
index 7f17387c9c..0d6843a3e5 100644
--- a/src/corelib/arch/qatomic_bootstrap.h
+++ b/src/corelib/arch/qatomic_bootstrap.h
@@ -67,8 +67,10 @@ template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
return --_q_value != 0;
}
- static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
+ static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
{
+ if (currentValue)
+ *currentValue = _q_value;
if (_q_value == expectedValue) {
_q_value = newValue;
return true;