From 5bfeab8749ce6820d55135b81665a7231d3b1504 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Jul 2011 23:46:19 +0200 Subject: Make all uses of QBasicAtomicInt and Pointer use load() and store() Most of these changes are search-and-replace of d->ref ==, d->ref != and d->ref =. The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to be basic, so I made it QAtomicPointer. Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6 Reviewed-on: http://codereview.qt-project.org/5030 Reviewed-by: Qt Sanity Bot Reviewed-by: Bradley T. Hughes Reviewed-by: Lars Knoll --- src/corelib/animation/qvariantanimation.cpp | 4 ++-- src/corelib/global/qglobal.h | 16 ++++++++-------- src/corelib/kernel/qmetatype.h | 8 ++++---- src/corelib/kernel/qobject.cpp | 4 ++-- src/corelib/kernel/qobject_p.h | 2 +- src/corelib/thread/qmutex.cpp | 23 ++++++++++------------- src/corelib/thread/qmutex.h | 2 +- src/corelib/thread/qmutex_linux.cpp | 12 ++++++------ src/corelib/tools/qcontiguouscache.h | 12 ++++++------ src/corelib/tools/qrefcount.h | 18 ++++++++++-------- src/corelib/tools/qshareddata.h | 4 ++-- src/corelib/tools/qsharedpointer.cpp | 6 +++--- src/corelib/tools/qsharedpointer_impl.h | 16 ++++++++-------- src/corelib/tools/qsimd.cpp | 8 ++++---- src/gui/painting/qregion.cpp | 10 +++++----- src/opengl/qglcolormap.cpp | 2 +- src/opengl/qglcolormap.h | 2 +- src/testlib/qtestlog.cpp | 2 +- 18 files changed, 75 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 4bfcd1db2a..7dfb4bddc1 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -292,11 +292,11 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress) qSwap(currentValue, ret); q->updateCurrentValue(currentValue); static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0); - if (!changedSignalIndex) { + if (!changedSignalIndex.load()) { //we keep the mask so that we emit valueChanged only when needed (for performance reasons) changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)")); } - if (isSignalConnected(changedSignalIndex) && currentValue != ret) { + if (isSignalConnected(changedSignalIndex.load()) && currentValue != ret) { //the value has changed emit q->valueChanged(currentValue); } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 2d2db2440d..228c9a3469 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1909,8 +1909,8 @@ public: inline ~QGlobalStaticDeleter() { - delete globalStatic.pointer; - globalStatic.pointer = 0; + delete globalStatic.pointer.load(); + globalStatic.pointer.store(0); globalStatic.destroyed = true; } }; @@ -1920,14 +1920,14 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ TYPE *x = new TYPE; \ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ delete x; \ else \ static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ @@ -1935,14 +1935,14 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ TYPE *x = new TYPE ARGS; \ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ delete x; \ else \ static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ @@ -1950,7 +1950,7 @@ public: { \ static QGlobalStatic thisGlobalStatic \ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \ + if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ QScopedPointer x(new TYPE); \ INITIALIZER; \ if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \ @@ -1958,7 +1958,7 @@ public: x.take(); \ } \ } \ - return thisGlobalStatic.pointer; \ + return thisGlobalStatic.pointer.load(); \ } #endif diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 5df7658a13..f7473e337c 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -273,10 +273,10 @@ inline int qRegisterMetaTypeStreamOperators() static int qt_metatype_id() \ { \ static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \ - if (!metatype_id) \ - metatype_id = qRegisterMetaType< TYPE >(#TYPE, \ - reinterpret_cast< TYPE *>(quintptr(-1))); \ - return metatype_id; \ + if (!metatype_id.load()) \ + metatype_id.storeRelease(qRegisterMetaType< TYPE >(#TYPE, \ + reinterpret_cast< TYPE *>(quintptr(-1)))); \ + return metatype_id.loadAcquire(); \ } \ }; \ QT_END_NAMESPACE diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0d7b840c3e..6e539d1722 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -808,13 +808,13 @@ QObject::~QObject() } if (d->sharedRefcount) { - if (d->sharedRefcount->strongref > 0) { + if (d->sharedRefcount->strongref.load() > 0) { qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash."); // but continue deleting, it's too late to stop anyway } // indicate to all QWeakPointers that this QObject has now been deleted - d->sharedRefcount->strongref = 0; + d->sharedRefcount->strongref.store(0); if (!d->sharedRefcount->weakref.deref()) delete d->sharedRefcount; } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index e7233c5ba9..b4c30bd149 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -120,7 +120,7 @@ public: //senders linked list Connection *next; Connection **prev; - QBasicAtomicPointer argumentTypes; + QAtomicPointer argumentTypes; ushort method_offset; ushort method_relative; ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index c90b44be6c..b2f52500fa 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -140,10 +140,7 @@ QT_BEGIN_NAMESPACE */ QMutex::QMutex(RecursionMode mode) { - if (mode == Recursive) - d = new QRecursiveMutexPrivate; - else - d = 0; + d.store(mode == Recursive ? new QRecursiveMutexPrivate : 0); } /*! @@ -154,10 +151,10 @@ QMutex::QMutex(RecursionMode mode) QMutex::~QMutex() { if (isRecursive()) - delete static_cast(d._q_value); - else if (d) { + delete static_cast(d.load()); + else if (d.load()) { #ifndef Q_OS_LINUX - if (d->possiblyUnlocked && tryLock()) { unlock(); return; } + if (d.load()->possiblyUnlocked && tryLock()) { unlock(); return; } #endif qWarning("QMutex: destroying locked mutex"); } @@ -236,7 +233,7 @@ QMutex::~QMutex() */ bool QBasicMutex::isRecursive() { - QMutexPrivate *d = this->d; + QMutexPrivate *d = this->d.load(); if (quintptr(d) <= 0x3) return false; return d->recursive; @@ -345,7 +342,7 @@ bool QBasicMutex::isRecursive() { bool QBasicMutex::lockInternal(int timeout) { while (!fastTryLock()) { - QMutexPrivate *d = this->d; + QMutexPrivate *d = this->d.loadAcquire(); if (!d) // if d is 0, the mutex is unlocked continue; @@ -370,7 +367,7 @@ bool QBasicMutex::lockInternal(int timeout) if (!d->ref()) continue; //that QMutexPrivate was already released - if (d != this->d) { + if (d != this->d.loadAcquire()) { //Either the mutex is already unlocked, or relocked with another mutex d->deref(); continue; @@ -389,7 +386,7 @@ bool QBasicMutex::lockInternal(int timeout) d->deref(); return true; } else { - Q_ASSERT(d != this->d); //else testAndSetAcquire should have succeeded + Q_ASSERT(d != this->d.load()); //else testAndSetAcquire should have succeeded // Mutex is likely to bo 0, we should continue the outer-loop, // set old_waiters to the magic value of BigNumber old_waiters = QMutexPrivate::BigNumber; @@ -398,7 +395,7 @@ bool QBasicMutex::lockInternal(int timeout) } } while (!d->waiters.testAndSetRelaxed(old_waiters, old_waiters + 1)); - if (d != this->d) { + if (d != this->d.loadAcquire()) { // Mutex was unlocked. if (old_waiters != QMutexPrivate::BigNumber) { //we did not break the previous loop @@ -436,7 +433,7 @@ bool QBasicMutex::lockInternal(int timeout) */ void QBasicMutex::unlockInternal() { - QMutexPrivate *d = this->d; + QMutexPrivate *d = this->d.loadAcquire(); Q_ASSERT(d); //we must be locked Q_ASSERT(d != dummyLocked()); // testAndSetRelease(dummyLocked(), 0) failed diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index a49b981d01..4bc2c87cda 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -65,7 +65,7 @@ public: } inline void unlock() { - Q_ASSERT(d); //mutex must be locked + Q_ASSERT(d.load()); //mutex must be locked if (!d.testAndSetRelease(dummyLocked(), 0)) unlockInternal(); } diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 17015b8f84..a3ca150a31 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -static inline int _q_futex(QMutexPrivate *volatile *addr, int op, int val, const struct timespec *timeout) +static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) { volatile int *int_addr = reinterpret_cast(addr); #if Q_BYTE_ORDER == Q_BIG_ENDIAN && QT_POINTER_SIZE == 8 @@ -82,7 +82,7 @@ bool QBasicMutex::lockInternal(int timeout) elapsedTimer.start(); while (!fastTryLock()) { - QMutexPrivate *d = this->d; + QMutexPrivate *d = this->d.load(); if (!d) // if d is 0, the mutex is unlocked continue; @@ -103,7 +103,7 @@ bool QBasicMutex::lockInternal(int timeout) ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000); pts = &ts; } - int r = _q_futex(&this->d._q_value, FUTEX_WAIT, quintptr(dummyFutexValue()), pts); + int r = _q_futex(&this->d, FUTEX_WAIT, quintptr(dummyFutexValue()), pts); if (r != 0 && errno == ETIMEDOUT) return false; } @@ -112,19 +112,19 @@ bool QBasicMutex::lockInternal(int timeout) Q_ASSERT(d->recursive); return static_cast(d)->lock(timeout); } - Q_ASSERT(this->d); + Q_ASSERT(this->d.load()); return true; } void QBasicMutex::unlockInternal() { - QMutexPrivate *d = this->d; + QMutexPrivate *d = this->d.load(); Q_ASSERT(d); //we must be locked Q_ASSERT(d != dummyLocked()); // testAndSetRelease(dummyLocked(), 0) failed if (d == dummyFutexValue()) { this->d.fetchAndStoreRelease(0); - _q_futex(&this->d._q_value, FUTEX_WAKE, 1, 0); + _q_futex(&this->d, FUTEX_WAKE, 1, 0); return; } diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 526d8fbc17..e192edf0ab 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -105,8 +105,8 @@ public: inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(p); } - inline void detach() { if (d->ref != 1) detach_helper(); } - inline bool isDetached() const { return d->ref == 1; } + inline void detach() { if (d->ref.load() != 1) detach_helper(); } + inline bool isDetached() const { return d->ref.load() == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } QContiguousCache &operator=(const QContiguousCache &other); @@ -185,7 +185,7 @@ void QContiguousCache::detach_helper() union { QContiguousCacheData *d; QContiguousCacheTypedData *p; } x; x.d = malloc(d->alloc); - x.d->ref = 1; + x.d->ref.store(1); x.d->count = d->count; x.d->start = d->start; x.d->offset = d->offset; @@ -258,7 +258,7 @@ void QContiguousCache::setCapacity(int asize) template void QContiguousCache::clear() { - if (d->ref == 1) { + if (d->ref.load() == 1) { if (QTypeInfo::isComplex) { int oldcount = d->count; T * i = p->array + d->start; @@ -274,7 +274,7 @@ void QContiguousCache::clear() } else { union { QContiguousCacheData *d; QContiguousCacheTypedData *p; } x; x.d = malloc(d->alloc); - x.d->ref = 1; + x.d->ref.store(1); x.d->alloc = d->alloc; x.d->count = x.d->start = x.d->offset = 0; x.d->sharable = true; @@ -293,7 +293,7 @@ template QContiguousCache::QContiguousCache(int cap) { d = malloc(cap); - d->ref = 1; + d->ref.store(1); d->alloc = cap; d->count = d->start = d->offset = 0; d->sharable = true; diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index e72ddf66b6..619f61e072 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -56,27 +56,29 @@ namespace QtPrivate class RefCount { public: - inline void ref() { - if (atomic > 0) + inline void ref() { + if (atomic.load() > 0) atomic.ref(); } inline bool deref() { - if (atomic <= 0) + if (atomic.load() <= 0) return true; return atomic.deref(); } inline bool operator==(int value) const - { return atomic.operator ==(value); } + { return atomic.load() == value; } inline bool operator!=(int value) const - { return atomic.operator !=(value); } + { return atomic.load() != value; } inline bool operator!() const - { return atomic.operator !(); } + { return !atomic.load(); } inline operator int() const - { return atomic.operator int(); } + { return atomic.load(); } inline RefCount &operator=(int value) - { atomic = value; return *this; } + { atomic.store(value); return *this; } + inline RefCount &operator=(const RefCount &other) + { atomic.store(other.atomic.load()); return *this; } QBasicAtomicInt atomic; }; diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 811b186e8b..6de6a19289 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -72,7 +72,7 @@ public: typedef T Type; typedef T *pointer; - inline void detach() { if (d && d->ref != 1) detach_helper(); } + inline void detach() { if (d && d->ref.load() != 1) detach_helper(); } inline T &operator*() { detach(); return *d; } inline const T &operator*() const { return *d; } inline T *operator->() { detach(); return d; } @@ -145,7 +145,7 @@ public: inline T *data() const { return d; } inline const T *constData() const { return d; } - inline void detach() { if (d && d->ref != 1) detach_helper(); } + inline void detach() { if (d && d->ref.load() != 1) detach_helper(); } inline void reset() { diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 873a2bf0d9..e9ae3cb4da 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1260,13 +1260,13 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge // we can create the refcount data because it doesn't exist ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized); - x->strongref = -1; - x->weakref = 2; // the QWeakPointer that called us plus the QObject itself + x->strongref.store(-1); + x->weakref.store(2); // the QWeakPointer that called us plus the QObject itself if (!d->sharedRefcount.testAndSetRelease(0, x)) { delete x; d->sharedRefcount->weakref.ref(); } - return d->sharedRefcount; + return d->sharedRefcount.loadAcquire(); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 47ad21a499..f03889106f 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -186,11 +186,11 @@ namespace QtSharedPointer { inline ExternalRefCountData() { - strongref = 1; - weakref = 1; + strongref.store(1); + weakref.store(1); } inline ExternalRefCountData(Qt::Initialization) { } - virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); } + virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref.load()); Q_ASSERT(strongref.load() <= 0); } // overridden by derived classes // returns false to indicate caller should delete the pointer @@ -432,12 +432,12 @@ namespace QtSharedPointer { if (o) { // increase the strongref, but never up from zero // or less (-1 is used by QWeakPointer on untracked QObject) - register int tmp = o->strongref; + register int tmp = o->strongref.load(); while (tmp > 0) { // try to increment from "tmp" to "tmp + 1" if (o->strongref.testAndSetRelaxed(tmp, tmp + 1)) break; // succeeded - tmp = o->strongref; // failed, try again + tmp = o->strongref.load(); // failed, try again } if (tmp > 0) @@ -448,7 +448,7 @@ namespace QtSharedPointer { qSwap(d, o); qSwap(this->value, actual); - if (!d || d->strongref == 0) + if (!d || d->strongref.load() == 0) this->value = 0; // dereference saved data @@ -577,14 +577,14 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - inline bool isNull() const { return d == 0 || d->strongref == 0 || value == 0; } + inline bool isNull() const { return d == 0 || d->strongref.load() == 0 || value == 0; } #ifndef Q_CC_NOKIAX86 inline operator RestrictedBool() const { return isNull() ? 0 : &QWeakPointer::value; } #else inline operator bool() const { return isNull() ? 0 : &QWeakPointer::value; } #endif inline bool operator !() const { return isNull(); } - inline T *data() const { return d == 0 || d->strongref == 0 ? 0 : value; } + inline T *data() const { return d == 0 || d->strongref.load() == 0 ? 0 : value; } inline QWeakPointer() : d(0), value(0) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 9bfb956c42..3dfe38a4d1 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -382,8 +382,8 @@ const int features_count = (sizeof features_indices - 1) / (sizeof features_indi uint qDetectCPUFeatures() { static QBasicAtomicInt features = Q_BASIC_ATOMIC_INITIALIZER(-1); - if (features != -1) - return features; + if (features.load() != -1) + return features.load(); uint f = detectProcessorFeatures(); QByteArray disable = qgetenv("QT_NO_CPU_FEATURE"); @@ -395,8 +395,8 @@ uint qDetectCPUFeatures() } } - features = f; - return features; + features.store(f); + return f; } void qDumpCPUFeatures() diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index f343fa9b4c..3f8e80c13d 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -261,7 +261,7 @@ QRegion::QRegion(int x, int y, int w, int h, RegionType t) void QRegion::detach() { - if (d->ref != 1) + if (d->ref.load() != 1) *this = copy(); #if defined(Q_WS_X11) else if (d->xrectangles) { @@ -3828,7 +3828,7 @@ QRegion::QRegion(const QRect &r, RegionType t) d->ref.ref(); } else { d = new QRegionData; - d->ref = 1; + d->ref.store(1); #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; @@ -3853,7 +3853,7 @@ QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); if (qt_rgn) { d = new QRegionData; - d->ref = 1; + d->ref.store(1); #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; @@ -3885,7 +3885,7 @@ QRegion::QRegion(const QBitmap &bm) d->ref.ref(); } else { d = new QRegionData; - d->ref = 1; + d->ref.store(1); #if defined(Q_WS_X11) d->rgn = 0; d->xrectangles = 0; @@ -3935,7 +3935,7 @@ QRegion QRegion::copy() const { QRegion r; QScopedPointer x(new QRegionData); - x->ref = 1; + x->ref.store(1); #if defined(Q_WS_X11) x->rgn = 0; x->xrectangles = 0; diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp index 492154ffcf..8ff2f9fa0a 100644 --- a/src/opengl/qglcolormap.cpp +++ b/src/opengl/qglcolormap.cpp @@ -154,7 +154,7 @@ QGLColormap & QGLColormap::operator=(const QGLColormap &map) void QGLColormap::detach_helper() { QGLColormapData *x = new QGLColormapData; - x->ref = 1; + x->ref.store(1); x->cmapHandle = 0; x->cells = 0; if (d->cells) { diff --git a/src/opengl/qglcolormap.h b/src/opengl/qglcolormap.h index d9e6ff98eb..cc8519173b 100644 --- a/src/opengl/qglcolormap.h +++ b/src/opengl/qglcolormap.h @@ -94,7 +94,7 @@ private: inline void QGLColormap::detach() { - if (d->ref != 1) + if (d->ref.load() != 1) detach_helper(); } diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index acd1a49d44..c812f6c69b 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -221,7 +221,7 @@ namespace QTest { return; if (type != QtFatalMsg) { - if (counter <= 0) + if (counter.load() <= 0) return; if (!counter.deref()) { -- cgit v1.2.3