From 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 11:08:29 +0200 Subject: Port from QAtomic::load() to loadRelaxed() Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz --- src/corelib/tools/qsharedpointer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib/tools/qsharedpointer.cpp') diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index e4de5a2ba9..f185d2f23f 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1380,7 +1380,7 @@ void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *, bo */ void QtSharedPointer::ExternalRefCountData::checkQObjectShared(const QObject *) { - if (strongref.load() < 0) + if (strongref.loadRelaxed() < 0) qWarning("QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer"); } @@ -1390,7 +1390,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge QObjectPrivate *d = QObjectPrivate::get(const_cast(obj)); Q_ASSERT_X(!d->wasDeleted, "QWeakPointer", "Detected QWeakPointer creation in a QObject being deleted"); - ExternalRefCountData *that = d->sharedRefcount.load(); + ExternalRefCountData *that = d->sharedRefcount.loadRelaxed(); if (that) { that->weakref.ref(); return that; @@ -1398,8 +1398,8 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge // we can create the refcount data because it doesn't exist ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized); - x->strongref.store(-1); - x->weakref.store(2); // the QWeakPointer that called us plus the QObject itself + x->strongref.storeRelaxed(-1); + x->weakref.storeRelaxed(2); // the QWeakPointer that called us plus the QObject itself ExternalRefCountData *ret; if (d->sharedRefcount.testAndSetOrdered(nullptr, x, ret)) { // ought to be release+acquire; this is acq_rel+acquire @@ -1407,7 +1407,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge } else { // ~ExternalRefCountData has a Q_ASSERT, so we use this trick to // only execute this if Q_ASSERTs are enabled - Q_ASSERT((x->weakref.store(0), true)); + Q_ASSERT((x->weakref.storeRelaxed(0), true)); delete x; ret->weakref.ref(); } -- cgit v1.2.3