summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/concurrent/qfutureinterface.cpp2
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentiteratekernel.h8
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.cpp10
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp2
-rw-r--r--src/corelib/kernel/qobject.cpp12
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/thread/qatomic.h2
-rw-r--r--src/corelib/thread/qmutex.cpp24
-rw-r--r--src/corelib/thread/qmutex_p.h10
-rw-r--r--src/corelib/thread/qmutexpool.cpp12
-rw-r--r--src/corelib/thread/qmutexpool_p.h2
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/tools/qregexp.cpp2
-rw-r--r--src/corelib/tools/qsharedpointer.cpp11
-rw-r--r--src/gui/image/qimage.cpp8
-rw-r--r--src/gui/image/qpicture.cpp2
-rw-r--r--src/gui/image/qpixmap.cpp10
-rw-r--r--src/gui/kernel/qevent.cpp36
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/kernel/qopenglcontext.cpp2
-rw-r--r--src/gui/kernel/qpalette.cpp2
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp2
-rw-r--r--src/gui/painting/qbrush.cpp8
-rw-r--r--src/gui/painting/qbrush.h2
-rw-r--r--src/gui/painting/qpainterpath.h2
-rw-r--r--src/gui/painting/qpainterpath_p.h2
-rw-r--r--src/gui/painting/qpen.cpp7
-rw-r--r--src/gui/text/qfont.cpp31
-rw-r--r--src/gui/text/qfontengine.cpp5
-rw-r--r--src/gui/text/qglyphrun.cpp2
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp2
-rw-r--r--src/gui/text/qrawfont.cpp4
-rw-r--r--src/gui/text/qrawfont_p.h2
-rw-r--r--src/gui/text/qstatictext.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--src/network/bearer/qbearerengine.cpp6
-rw-r--r--src/network/kernel/qnetworkproxy.cpp4
-rw-r--r--src/opengl/qgl.cpp4
-rw-r--r--src/opengl/qglframebufferobject.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm5
-rw-r--r--src/sql/kernel/qsqldatabase.cpp2
-rw-r--r--src/sql/kernel/qsqlquery.cpp4
-rw-r--r--src/widgets/kernel/qicon.cpp4
-rw-r--r--src/xml/dom/qdom.cpp2
49 files changed, 140 insertions, 143 deletions
diff --git a/src/corelib/concurrent/qfutureinterface.cpp b/src/corelib/concurrent/qfutureinterface.cpp
index 74c3af0ce0..f54b335403 100644
--- a/src/corelib/concurrent/qfutureinterface.cpp
+++ b/src/corelib/concurrent/qfutureinterface.cpp
@@ -416,7 +416,7 @@ QFutureInterfaceBase &QFutureInterfaceBase::operator=(const QFutureInterfaceBase
bool QFutureInterfaceBase::referenceCountIsOne() const
{
- return d->refCount == 1;
+ return d->refCount.load() == 1;
}
QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState)
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index 5c5d65dc71..c9a16a8bbf 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -464,7 +464,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
emit q->resultsReadyAt(beginIndex, endIndex);
- if (int(resultAtConnected) <= 0)
+ if (resultAtConnected.load() <= 0)
break;
for (int i = beginIndex; i < endIndex; ++i)
diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.h b/src/corelib/concurrent/qtconcurrentiteratekernel.h
index c6fcb973ab..49c053caf7 100644
--- a/src/corelib/concurrent/qtconcurrentiteratekernel.h
+++ b/src/corelib/concurrent/qtconcurrentiteratekernel.h
@@ -214,9 +214,9 @@ public:
bool shouldStartThread()
{
if (forIteration)
- return (currentIndex < iterationCount) && !this->shouldThrottleThread();
+ return (currentIndex.load() < iterationCount) && !this->shouldThrottleThread();
else // whileIteration
- return (iteratorThreads == 0);
+ return (iteratorThreads.load() == 0);
}
ThreadFunctionResult threadFunction()
@@ -238,7 +238,7 @@ public:
const int currentBlockSize = blockSizeManager.blockSize();
- if (currentIndex >= iterationCount)
+ if (currentIndex.load() >= iterationCount)
break;
// Atomically reserve a block of iterationCount for this thread.
@@ -269,7 +269,7 @@ public:
// Report progress if progress reporting enabled.
if (progressReportingEnabled) {
completed.fetchAndAddAcquire(finalBlockSize);
- this->setProgressValue(this->completed);
+ this->setProgressValue(this->completed.load());
}
if (this->shouldThrottleThread())
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.cpp b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
index bb9b0800c9..71a47164d2 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.cpp
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
@@ -53,7 +53,7 @@ ThreadEngineBarrier::ThreadEngineBarrier()
void ThreadEngineBarrier::acquire()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount < 0) {
if (count.testAndSetOrdered(localCount, localCount -1))
return;
@@ -67,7 +67,7 @@ void ThreadEngineBarrier::acquire()
int ThreadEngineBarrier::release()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount == -1) {
if (count.testAndSetOrdered(-1, 0)) {
semaphore.release();
@@ -87,7 +87,7 @@ int ThreadEngineBarrier::release()
void ThreadEngineBarrier::wait()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount == 0)
return;
@@ -101,7 +101,7 @@ void ThreadEngineBarrier::wait()
int ThreadEngineBarrier::currentCount()
{
- return int(count);
+ return count.load();
}
// releases a thread, unless this is the last thread.
@@ -109,7 +109,7 @@ int ThreadEngineBarrier::currentCount()
bool ThreadEngineBarrier::releaseUnlessLast()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (qAbs(localCount) == 1) {
return false;
} else if (localCount < 0) {
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 9adb331a13..5bebff089e 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -184,7 +184,7 @@ public:
template<> Q_INLINE_TEMPLATE void QSharedDataPointer<QProcessEnvironmentPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QProcessEnvironmentPrivate *x = (d ? new QProcessEnvironmentPrivate(*d)
: new QProcessEnvironmentPrivate);
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 6dca036e05..b960528fb8 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -6102,7 +6102,7 @@ void QUrl::detach()
*/
bool QUrl::isDetached() const
{
- return !d || d->ref == 1;
+ return !d || d->ref.load() == 1;
}
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index b7ac6aa594..bda25c301e 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -74,7 +74,7 @@ QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex &
void QPersistentModelIndexData::destroy(QPersistentModelIndexData *data)
{
Q_ASSERT(data);
- Q_ASSERT(data->ref == 0);
+ Q_ASSERT(data->ref.load() == 0);
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(data->model);
// a valid persistent model index with a null model pointer can only happen if the model was destroyed
if (model) {
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4c969c8f4a..555bfa674d 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -807,19 +807,19 @@ QObject::~QObject()
QObjectPrivate::clearGuards(this);
}
- if (d->sharedRefcount) {
- if (d->sharedRefcount->strongref.load() > 0) {
+ QtSharedPointer::ExternalRefCountData *sharedRefcount = d->sharedRefcount.load();
+ if (sharedRefcount) {
+ if (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.store(0);
- if (!d->sharedRefcount->weakref.deref())
- delete d->sharedRefcount;
+ sharedRefcount->strongref.store(0);
+ if (!sharedRefcount->weakref.deref())
+ delete sharedRefcount;
}
-
if (d->isSignalConnected(0)) {
QT_TRY {
emit destroyed(this);
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 76957f106a..470be1c0b0 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1823,7 +1823,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
void QVariant::detach()
{
- if (!d.is_shared || d.data.shared->ref == 1)
+ if (!d.is_shared || d.data.shared->ref.load() == 1)
return;
Private dd;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index e77fc90b92..61dc48ad94 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -448,7 +448,7 @@ Q_CORE_EXPORT QDataStream& operator<< (QDataStream& s, const QVariant::Type p);
#endif
inline bool QVariant::isDetached() const
-{ return !d.is_shared || d.data.shared->ref == 1; }
+{ return !d.is_shared || d.data.shared->ref.load() == 1; }
#ifdef qdoc
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index 6fe4d65832..0b72ce9adf 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -259,7 +259,7 @@ inline void qAtomicAssign(T *&d, T *x)
template <typename T>
inline void qAtomicDetach(T *&d)
{
- if (d->ref == 1)
+ if (d->ref.load() == 1)
return;
T *x = d;
d = new T(*d);
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index e2da0adf17..959d1f958a 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -154,7 +154,7 @@ QMutex::~QMutex()
delete static_cast<QRecursiveMutexPrivate *>(d.load());
else if (d.load()) {
#ifndef Q_OS_LINUX
- if (d.load()->possiblyUnlocked && tryLock()) { unlock(); return; }
+ if (d.load()->possiblyUnlocked.load() && tryLock()) { unlock(); return; }
#endif
qWarning("QMutex: destroying locked mutex");
}
@@ -361,7 +361,7 @@ bool QBasicMutex::lockInternal(int timeout)
return static_cast<QRecursiveMutexPrivate *>(d)->lock(timeout);
}
- if (timeout == 0 && !d->possiblyUnlocked)
+ if (timeout == 0 && !d->possiblyUnlocked.load())
return false;
if (!d->ref())
@@ -375,7 +375,7 @@ bool QBasicMutex::lockInternal(int timeout)
int old_waiters;
do {
- old_waiters = d->waiters;
+ old_waiters = d->waiters.load();
if (old_waiters == -QMutexPrivate::BigNumber) {
// we are unlocking, and the thread that unlocks is about to change d to 0
// we try to aquire the mutex by changing to dummyLocked()
@@ -407,7 +407,7 @@ bool QBasicMutex::lockInternal(int timeout)
}
if (d->wait(timeout)) {
- if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false))
+ if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false))
d->deref();
d->derefWaiters(1);
//we got the lock. (do not deref)
@@ -445,7 +445,7 @@ void QBasicMutex::unlockInternal()
if (d->waiters.fetchAndAddRelease(-QMutexPrivate::BigNumber) == 0) {
//there is no one waiting on this mutex anymore, set the mutex as unlocked (d = 0)
if (this->d.testAndSetRelease(d, 0)) {
- if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false))
+ if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false))
d->deref();
}
d->derefWaiters(0);
@@ -479,10 +479,10 @@ QMutexPrivate *QMutexPrivate::allocate()
int i = freelist()->next();
QMutexPrivate *d = &(*freelist())[i];
d->id = i;
- Q_ASSERT(d->refCount == 0);
+ Q_ASSERT(d->refCount.load() == 0);
Q_ASSERT(!d->recursive);
- Q_ASSERT(!d->possiblyUnlocked);
- Q_ASSERT(d->waiters == 0);
+ Q_ASSERT(!d->possiblyUnlocked.load());
+ Q_ASSERT(d->waiters.load() == 0);
d->refCount = 1;
return d;
}
@@ -490,9 +490,9 @@ QMutexPrivate *QMutexPrivate::allocate()
void QMutexPrivate::release()
{
Q_ASSERT(!recursive);
- Q_ASSERT(refCount == 0);
- Q_ASSERT(!possiblyUnlocked);
- Q_ASSERT(waiters == 0);
+ Q_ASSERT(refCount.load() == 0);
+ Q_ASSERT(!possiblyUnlocked.load());
+ Q_ASSERT(waiters.load() == 0);
freelist()->release(id);
}
@@ -502,7 +502,7 @@ void QMutexPrivate::derefWaiters(int value)
int old_waiters;
int new_waiters;
do {
- old_waiters = waiters;
+ old_waiters = waiters.load();
new_waiters = old_waiters;
if (new_waiters < 0) {
new_waiters += QMutexPrivate::BigNumber;
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 00f071ebef..00bda48e5b 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -79,21 +79,21 @@ public:
int id;
bool ref() {
- Q_ASSERT(refCount >= 0);
+ Q_ASSERT(refCount.load() >= 0);
int c;
do {
- c = refCount;
+ c = refCount.load();
if (c == 0)
return false;
} while (!refCount.testAndSetRelaxed(c, c + 1));
- Q_ASSERT(refCount >= 0);
+ Q_ASSERT(refCount.load() >= 0);
return true;
}
void deref() {
- Q_ASSERT(refCount >=0);
+ Q_ASSERT(refCount.load() >= 0);
if (!refCount.deref())
release();
- Q_ASSERT(refCount >=0);
+ Q_ASSERT(refCount.load() >= 0);
}
void release();
static QMutexPrivate *allocate();
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 49fb46b0f4..ef4e9560fb 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -99,7 +99,7 @@ QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
: mutexes(size), recursionMode(recursionMode)
{
for (int index = 0; index < mutexes.count(); ++index) {
- mutexes[index] = 0;
+ mutexes[index].store(0);
}
}
@@ -109,10 +109,8 @@ QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size)
*/
QMutexPool::~QMutexPool()
{
- for (int index = 0; index < mutexes.count(); ++index) {
- delete mutexes[index];
- mutexes[index] = 0;
- }
+ for (int index = 0; index < mutexes.count(); ++index)
+ delete mutexes[index].load();
}
/*!
@@ -136,9 +134,9 @@ QMutex *QMutexPool::createMutex(int index)
{
// mutex not created, create one
QMutex *newMutex = new QMutex(recursionMode);
- if (!mutexes[index].testAndSetOrdered(0, newMutex))
+ if (!mutexes[index].testAndSetRelease(0, newMutex))
delete newMutex;
- return mutexes[index];
+ return mutexes[index].load();
}
/*!
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index fa9a734065..20449c24d4 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -69,7 +69,7 @@ public:
inline QMutex *get(const void *address) {
int index = uint(quintptr(address)) % mutexes.count();
- QMutex *m = mutexes[index];
+ QMutex *m = mutexes[index].load();
if (m)
return m;
else
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 40cb258e7e..31332cd521 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -85,7 +85,7 @@ QThreadData::QThreadData(int initialRefCount)
QThreadData::~QThreadData()
{
- Q_ASSERT(_ref == 0);
+ Q_ASSERT(_ref.load() == 0);
// In the odd case that Qt is running on a secondary thread, the main
// thread instance will have been dereffed asunder because of the deref in
@@ -117,7 +117,7 @@ void QThreadData::ref()
{
#ifndef QT_NO_THREAD
(void) _ref.ref();
- Q_ASSERT(_ref != 0);
+ Q_ASSERT(_ref.load() != 0);
#endif
}
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 59a54f3eb7..433939fe3e 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1701,7 +1701,7 @@ void QRegExpEngine::dump() const
void QRegExpEngine::setup()
{
- ref = 1;
+ ref.store(1);
#ifndef QT_NO_REGEXP_CAPTURE
f.resize(32);
nf = 0;
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index e9ae3cb4da..34060926c7 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1238,9 +1238,9 @@ void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *obj,
Q_ASSERT(obj);
QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
- if (d->sharedRefcount)
+ if (d->sharedRefcount.load() != 0)
qFatal("QSharedPointer: pointer %p already has reference counting", obj);
- d->sharedRefcount = this;
+ d->sharedRefcount.store(this);
// QObject decreases the refcount too, so increase it up
weakref.ref();
@@ -1252,7 +1252,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge
QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
Q_ASSERT_X(!d->wasDeleted, "QWeakPointer", "Detected QWeakPointer creation in a QObject being deleted");
- ExternalRefCountData *that = d->sharedRefcount;
+ ExternalRefCountData *that = d->sharedRefcount.load();
if (that) {
that->weakref.ref();
return that;
@@ -1264,9 +1264,10 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge
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();
+ x = d->sharedRefcount.loadAcquire();
+ x->weakref.ref();
}
- return d->sharedRefcount.loadAcquire();
+ return x;
}
QT_END_NAMESPACE
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index c74b715f8d..a19b608216 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1075,10 +1075,10 @@ QImage::operator QVariant() const
void QImage::detach()
{
if (d) {
- if (d->is_cached && d->ref == 1)
+ if (d->is_cached && d->ref.load() == 1)
QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
- if (d->ref != 1 || d->ro_data)
+ if (d->ref.load() != 1 || d->ro_data)
*this = copy();
if (d)
@@ -5289,7 +5289,7 @@ qint64 QImage::cacheKey() const
bool QImage::isDetached() const
{
- return d && d->ref == 1;
+ return d && d->ref.load() == 1;
}
@@ -5849,7 +5849,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla
return true;
// No in-place conversion if we have to detach
- if (ref > 1)
+ if (ref.load() > 1)
return false;
const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat];
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 5d79f3fe22..dfc84c56d8 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -226,7 +226,7 @@ void QPicture::detach()
bool QPicture::isDetached() const
{
- return d_func()->ref == 1;
+ return d_func()->ref.load() == 1;
}
/*!
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index c025aa9283..2a2bd5d6fa 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -272,7 +272,7 @@ QPixmap::QPixmap(const char * const xpm[])
QPixmap::~QPixmap()
{
- Q_ASSERT(!data || data->ref >= 1); // Catch if ref-counting changes again
+ Q_ASSERT(!data || data->ref.load() >= 1); // Catch if ref-counting changes again
}
/*!
@@ -871,7 +871,7 @@ void QPixmap::fill(const QColor &color)
return;
}
- if (data->ref == 1) {
+ if (data->ref.load() == 1) {
// detach() will also remove this pixmap from caches, so
// it has to be called even when ref == 1.
detach();
@@ -1000,7 +1000,7 @@ QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap)
bool QPixmap::isDetached() const
{
- return data && data->ref == 1;
+ return data && data->ref.load() == 1;
}
/*! \internal
@@ -1529,10 +1529,10 @@ void QPixmap::detach()
rasterData->image.detach();
}
- if (data->is_cached && data->ref == 1)
+ if (data->is_cached && data->ref.load() == 1)
QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
- if (data->ref != 1) {
+ if (data->ref.load() != 1) {
*this = copy();
}
++data->detach_no;
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index c9e49ef700..ba81e5512c 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3761,7 +3761,7 @@ qreal QTouchEvent::TouchPoint::pressure() const
/*! \internal */
void QTouchEvent::TouchPoint::setId(int id)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->id = id;
}
@@ -3769,7 +3769,7 @@ void QTouchEvent::TouchPoint::setId(int id)
/*! \internal */
void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->state = state;
}
@@ -3777,7 +3777,7 @@ void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
/*! \internal */
void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->rect.moveCenter(pos);
}
@@ -3785,7 +3785,7 @@ void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
/*! \internal */
void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->sceneRect.moveCenter(scenePos);
}
@@ -3793,7 +3793,7 @@ void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
/*! \internal */
void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->screenRect.moveCenter(screenPos);
}
@@ -3801,7 +3801,7 @@ void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
/*! \internal */
void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->normalizedPos = normalizedPos;
}
@@ -3809,7 +3809,7 @@ void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
/*! \internal */
void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startPos = startPos;
}
@@ -3817,7 +3817,7 @@ void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
/*! \internal */
void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startScenePos = startScenePos;
}
@@ -3825,7 +3825,7 @@ void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
/*! \internal */
void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startScreenPos = startScreenPos;
}
@@ -3833,7 +3833,7 @@ void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
/*! \internal */
void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startNormalizedPos = startNormalizedPos;
}
@@ -3841,7 +3841,7 @@ void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormaliz
/*! \internal */
void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastPos = lastPos;
}
@@ -3849,7 +3849,7 @@ void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
/*! \internal */
void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastScenePos = lastScenePos;
}
@@ -3857,7 +3857,7 @@ void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
/*! \internal */
void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastScreenPos = lastScreenPos;
}
@@ -3865,7 +3865,7 @@ void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
/*! \internal */
void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastNormalizedPos = lastNormalizedPos;
}
@@ -3873,7 +3873,7 @@ void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalized
/*! \internal */
void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->rect = rect;
}
@@ -3881,7 +3881,7 @@ void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
/*! \internal */
void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->sceneRect = sceneRect;
}
@@ -3889,7 +3889,7 @@ void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
/*! \internal */
void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->screenRect = screenRect;
}
@@ -3897,7 +3897,7 @@ void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
/*! \internal */
void QTouchEvent::TouchPoint::setPressure(qreal pressure)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->pressure = pressure;
}
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 2b42aaa119..6ea502b70b 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1600,7 +1600,7 @@ bool QKeySequence::operator< (const QKeySequence &other) const
*/
bool QKeySequence::isDetached() const
{
- return d->ref == 1;
+ return d->ref.load() == 1;
}
/*!
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index b3ce22448d..2b2f13e4bd 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -544,7 +544,7 @@ QOpenGLMultiGroupSharedResource::~QOpenGLMultiGroupSharedResource()
active.deref();
}
#ifndef QT_NO_DEBUG
- if (active != 0) {
+ if (active.load() != 0) {
qWarning("QtGui: Resources are still available at program shutdown.\n"
" This is possibly caused by a leaked QOpenGLWidget, \n"
" QOpenGLFramebufferObject or QOpenGLPixelBuffer.");
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index f84a366781..893cc5eff6 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -753,7 +753,7 @@ bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
*/
void QPalette::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QPalettePrivate *x = new QPalettePrivate;
for(int grp = 0; grp < (int)NColorGroups; grp++) {
for(int role = 0; role < (int)NColorRoles; role++)
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 6326033ff2..33b04cc708 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -120,7 +120,7 @@ QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) :
*/
void QSurfaceFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d);
if (!d->ref.deref())
delete d;
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index f08cab81d6..5e7f527c88 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
*/
void QOpenGLFramebufferObjectFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QOpenGLFramebufferObjectFormatPrivate *newd
= new QOpenGLFramebufferObjectFormatPrivate(d);
if (!d->ref.deref())
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index d1130a8812..b4aa27db2f 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -343,7 +343,7 @@ public:
QBrushData *brush;
QNullBrushData() : brush(new QBrushData)
{
- brush->ref = 1;
+ brush->ref.store(1);
brush->style = Qt::BrushStyle(0);
brush->color = Qt::black;
}
@@ -402,7 +402,7 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
d.reset(new QBrushData);
break;
}
- d->ref = 1;
+ d->ref.store(1);
d->style = style;
d->color = color;
}
@@ -577,7 +577,7 @@ void QBrush::cleanUp(QBrushData *x)
void QBrush::detach(Qt::BrushStyle newStyle)
{
- if (newStyle == d->style && d->ref == 1)
+ if (newStyle == d->style && d->ref.load() == 1)
return;
QScopedPointer<QBrushData> x;
@@ -605,7 +605,7 @@ void QBrush::detach(Qt::BrushStyle newStyle)
x.reset(new QBrushData);
break;
}
- x->ref = 1;
+ x->ref.store(1);
x->style = newStyle;
x->color = d->color;
x->transform = d->transform;
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 80d9b43f1f..daad47cb19 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -174,7 +174,7 @@ inline Qt::BrushStyle QBrush::style() const { return d->style; }
inline const QColor &QBrush::color() const { return d->color; }
inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); }
inline QTransform QBrush::transform() const { return d->transform; }
-inline bool QBrush::isDetached() const { return d->ref == 1; }
+inline bool QBrush::isDetached() const { return d->ref.load() == 1; }
/*******************************************************************************
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index a2dfed63c8..9dc435f630 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -419,7 +419,7 @@ inline void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
inline void QPainterPath::detach()
{
- if (d_ptr->ref != 1)
+ if (d_ptr->ref.load() != 1)
detach_helper();
setDirty(true);
}
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 1b5da7ee17..93cc11c8ee 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -245,7 +245,7 @@ inline bool QPainterPathData::isClosed() const
inline void QPainterPathData::close()
{
- Q_ASSERT(ref == 1);
+ Q_ASSERT(ref.load() == 1);
require_moveTo = true;
const QPainterPath::Element &first = elements.at(cStart);
QPainterPath::Element &last = elements.last();
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index a79e3a0cd2..5a4582e31e 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -230,10 +230,9 @@ typedef QPenPrivate QPenData;
*/
inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle penStyle,
Qt::PenCapStyle _capStyle, Qt::PenJoinStyle _joinStyle)
- : dashOffset(0), miterLimit(2),
+ : ref(1), dashOffset(0), miterLimit(2),
cosmetic(false)
{
- ref = 1;
width = _width;
brush = _brush;
style = penStyle;
@@ -353,7 +352,7 @@ QPen::~QPen()
void QPen::detach()
{
- if (d->ref == 1)
+ if (d->ref.load() == 1)
return;
QPenData *x = new QPenData(*static_cast<QPenData *>(d));
@@ -860,7 +859,7 @@ bool QPen::operator==(const QPen &p) const
bool QPen::isDetached()
{
- return d->ref == 1;
+ return d->ref.load() == 1;
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 7cd9fb15e9..23fe5ca4fb 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -667,7 +667,7 @@ QFont::QFont(QFontPrivate *data)
*/
void QFont::detach()
{
- if (d->ref == 1) {
+ if (d->ref.load() == 1) {
if (d->engineData)
d->engineData->ref.deref();
d->engineData = 0;
@@ -2631,11 +2631,11 @@ QFontCache::~QFontCache()
EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
end = engineDataCache.constEnd();
while (it != end) {
- if (it.value()->ref == 0)
+ if (it.value()->ref.load() == 0)
delete it.value();
else
FC_DEBUG("QFontCache::~QFontCache: engineData %p still has refcount %d",
- it.value(), int(it.value()->ref));
+ it.value(), it.value()->ref.load());
++it;
}
}
@@ -2643,7 +2643,7 @@ QFontCache::~QFontCache()
end = engineCache.constEnd();
while (it != end) {
if (--it.value().data->cache_count == 0) {
- if (it.value().data->ref == 0) {
+ if (it.value().data->ref.load() == 0) {
FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %g %d %d %d)",
it.value().data, it.key().script, it.key().def.pointSize,
it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
@@ -2652,7 +2652,7 @@ QFontCache::~QFontCache()
delete it.value().data;
} else {
FC_DEBUG("QFontCache::~QFontCache: engine = %p still has refcount %d",
- it.value().data, int(it.value().data->ref));
+ it.value().data, it.value().data->ref.load());
}
}
++it;
@@ -2678,7 +2678,7 @@ void QFontCache::clear()
for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end();
it != end; ++it) {
- if (it->data->ref == 0) {
+ if (it->data->ref.load() == 0) {
delete it->data;
it->data = 0;
}
@@ -2686,7 +2686,7 @@ void QFontCache::clear()
for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end();
it != end; ++it) {
- if (it->data && it->data->ref == 0) {
+ if (it->data && it->data->ref.load() == 0) {
delete it->data;
it->data = 0;
}
@@ -2727,7 +2727,7 @@ QFontEngine *QFontCache::findEngine(const Key &key)
FC_DEBUG("QFontCache: found font engine\n"
" %p: timestamp %4u hits %3u ref %2d/%2d, type '%s'",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->name());
return it.value().data;
@@ -2782,7 +2782,6 @@ void QFontCache::decreaseCost(uint cost)
cost, total_cost, max_cost);
}
-
void QFontCache::timerEvent(QTimerEvent *)
{
FC_DEBUG("QFontCache::timerEvent: performing cache maintenance (timestamp %u)",
@@ -2816,7 +2815,7 @@ void QFontCache::timerEvent(QTimerEvent *)
#endif // QFONTCACHE_DEBUG
- if (it.value()->ref != 0)
+ if (it.value()->ref.load() != 0)
in_use_cost += engine_data_cost;
}
}
@@ -2829,10 +2828,10 @@ void QFontCache::timerEvent(QTimerEvent *)
for (; it != end; ++it) {
FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->cache_cost);
- if (it.value().data->ref != 0)
+ if (it.value().data->ref.load() != 0)
in_use_cost += it.value().data->cache_cost / it.value().data->cache_count;
}
@@ -2882,7 +2881,7 @@ void QFontCache::timerEvent(QTimerEvent *)
EngineDataCache::Iterator it = engineDataCache.begin(),
end = engineDataCache.end();
while (it != end) {
- if (it.value()->ref != 0) {
+ if (it.value()->ref.load() != 0) {
++it;
continue;
}
@@ -2910,7 +2909,7 @@ void QFontCache::timerEvent(QTimerEvent *)
uint least_popular = ~0u;
for (; it != end; ++it) {
- if (it.value().data->ref != 0)
+ if (it.value().data->ref.load() != 0)
continue;
if (it.value().timestamp < oldest &&
@@ -2923,7 +2922,7 @@ void QFontCache::timerEvent(QTimerEvent *)
FC_DEBUG(" oldest %u least popular %u", oldest, least_popular);
for (it = engineCache.begin(); it != end; ++it) {
- if (it.value().data->ref == 0 &&
+ if (it.value().data->ref.load() == 0 &&
it.value().timestamp == oldest &&
it.value().hits == least_popular)
break;
@@ -2932,7 +2931,7 @@ void QFontCache::timerEvent(QTimerEvent *)
if (it != end) {
FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, type '%s'",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->name());
if (--it.value().data->cache_count == 0) {
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 3f008064e2..067a630d4d 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -168,9 +168,8 @@ static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB
// QFontEngine
QFontEngine::QFontEngine()
- : QObject()
+ : QObject(), ref(0)
{
- ref = 0;
cache_count = 0;
fsType = 0;
symbol = false;
@@ -1360,7 +1359,7 @@ QFontEngineMulti::~QFontEngineMulti()
QFontEngine *fontEngine = engines.at(i);
if (fontEngine) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
}
}
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index 0457202a18..2ab339e388 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -138,7 +138,7 @@ QGlyphRun::~QGlyphRun()
*/
void QGlyphRun::detach()
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d.detach();
}
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index 80ad31cea3..8d5a9201d9 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -194,7 +194,7 @@ QSupportedWritingSystems::~QSupportedWritingSystems()
*/
void QSupportedWritingSystems::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d);
if (!d->ref.deref())
delete d;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 389c5bdc75..8fccd9b0ca 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -683,7 +683,7 @@ void QRawFont::setPixelSize(qreal pixelSize)
d->fontEngine->ref.ref();
oldFontEngine->ref.deref();
- if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
+ if (oldFontEngine->cache_count == 0 && oldFontEngine->ref.load() == 0)
delete oldFontEngine;
}
@@ -695,7 +695,7 @@ void QRawFontPrivate::cleanUp()
platformCleanUp();
if (fontEngine != 0) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
fontEngine = 0;
}
diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h
index 1f2e957906..992cb2f720 100644
--- a/src/gui/text/qrawfont_p.h
+++ b/src/gui/text/qrawfont_p.h
@@ -84,7 +84,7 @@ public:
~QRawFontPrivate()
{
- Q_ASSERT(ref == 0);
+ Q_ASSERT(ref.load() == 0);
cleanUp();
}
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index bed0da62da..a52cf25a98 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -177,7 +177,7 @@ QStaticText::QStaticText(const QStaticText &other)
*/
QStaticText::~QStaticText()
{
- Q_ASSERT(!data || data->ref >= 1);
+ Q_ASSERT(!data || data->ref.load() >= 1);
}
/*!
@@ -185,7 +185,7 @@ QStaticText::~QStaticText()
*/
void QStaticText::detach()
{
- if (data->ref != 1)
+ if (data->ref.load() != 1)
data.detach();
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 3a2431d1ea..08d3a4df6e 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1219,7 +1219,7 @@ static inline void releaseCachedFontEngine(QFontEngine *fontEngine)
{
if (fontEngine) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
}
}
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
index 4dc2145511..b761eb2e9b 100644
--- a/src/network/bearer/qbearerengine.cpp
+++ b/src/network/bearer/qbearerengine.cpp
@@ -96,19 +96,19 @@ bool QBearerEngine::configurationsInUse() const
for (it = accessPointConfigurations.constBegin(),
end = accessPointConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
for (it = snapConfigurations.constBegin(),
end = snapConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
for (it = userChoiceConfigurations.constBegin(),
end = userChoiceConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 1062663b23..6beb52c5b0 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -411,7 +411,7 @@ public:
template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QNetworkProxyPrivate *x = (d ? new QNetworkProxyPrivate(*d)
: new QNetworkProxyPrivate);
@@ -727,7 +727,7 @@ public:
template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QNetworkProxyQueryPrivate *x = (d ? new QNetworkProxyQueryPrivate(*d)
: new QNetworkProxyQueryPrivate);
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 38b8e44c0b..52b2ae329e 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -333,7 +333,7 @@ QGLFormat::QGLFormat(QGL::FormatOptions options, int plane)
*/
void QGLFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QGLFormatPrivate *newd = new QGLFormatPrivate(d);
if (!d->ref.deref())
delete d;
@@ -4907,7 +4907,7 @@ void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *shar
return;
// Make sure 'context' is not already shared with another group of contexts.
- Q_ASSERT(context->d_ptr->group->m_refs == 1);
+ Q_ASSERT(context->d_ptr->group->m_refs.load() == 1);
// Free 'context' group resources and make it use the same resources as 'share'.
QGLContextGroup *group = share->d_ptr->group;
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 75c1bbe99e..60104c68c5 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -106,7 +106,7 @@ extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
*/
void QGLFramebufferObjectFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QGLFramebufferObjectFormatPrivate *newd
= new QGLFramebufferObjectFormatPrivate(d);
if (!d->ref.deref())
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 84ee4750a4..8cdf40be78 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -983,8 +983,9 @@ void processPostedEvents(QCocoaEventDispatcherPrivate *const d, const bool block
return;
}
- if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) {
- d->lastSerial = d->serialNumber;
+ int serial = d->serialNumber.load();
+ if (!d->threadData->canWait || (serial != d->lastSerial)) {
+ d->lastSerial = serial;
QWindowSystemInterface::sendWindowSystemEvents(d->q_func(), QEventLoop::AllEvents);
}
}
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index cd36d5d591..a53120c460 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -234,7 +234,7 @@ QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null()
void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn)
{
- if (db.d->ref != 1 && doWarn) {
+ if (db.d->ref.load() != 1 && doWarn) {
qWarning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, "
"all queries will cease to work.", name.toLocal8Bit().constData());
db.d->disable();
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 361730a83f..4eb46f1790 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -348,7 +348,7 @@ bool QSqlQuery::isNull(int field) const
bool QSqlQuery::exec(const QString& query)
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
bool fo = isForwardOnly();
*this = QSqlQuery(driver()->createResult());
d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy());
@@ -895,7 +895,7 @@ void QSqlQuery::clear()
*/
bool QSqlQuery::prepare(const QString& query)
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
bool fo = isForwardOnly();
*this = QSqlQuery(driver()->createResult());
setForwardOnly(fo);
diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp
index e1ba8d4306..de7544f09a 100644
--- a/src/widgets/kernel/qicon.cpp
+++ b/src/widgets/kernel/qicon.cpp
@@ -767,7 +767,7 @@ bool QIcon::isNull() const
*/
bool QIcon::isDetached() const
{
- return !d || d->ref == 1;
+ return !d || d->ref.load() == 1;
}
/*! \internal
@@ -775,7 +775,7 @@ bool QIcon::isDetached() const
void QIcon::detach()
{
if (d) {
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QIconPrivate *x = new QIconPrivate;
if (d->engine_version > 1) {
QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(d->engine);
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 7c7cafc1a0..29798d8a85 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -4509,7 +4509,7 @@ void QDomElementPrivate::setAttributeNS(const QString& nsURI, const QString& qNa
void QDomElementPrivate::removeAttribute(const QString& aname)
{
QDomNodePrivate* p = m_attr->removeNamedItem(aname);
- if (p && p->ref == 0)
+ if (p && p->ref.load() == 0)
delete p;
}