diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-09-29 11:50:08 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-27 18:57:38 +0200 |
commit | 6476ac738ca029af95932f53b53f0705808eb80e (patch) | |
tree | d1884397040eb65d23a48a0e1a56dad3f476cf34 /src/corelib/tools/qsharedpointer.cpp | |
parent | 434824aede28e8c36d6991aa218f89daf2cc22fa (diff) |
Replace implicit QAtomic* casts with explicit load()/store()
Change-Id: Ia7ef1a8e01001f203e409c710c977d6f4686342e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qsharedpointer.cpp')
-rw-r--r-- | src/corelib/tools/qsharedpointer.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
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 |