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 --- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 80 +++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp') diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 65709e3afa..1c9818696e 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -207,8 +207,8 @@ void tst_QSharedPointer::basics() QVERIFY(! (ptr == otherData)); QVERIFY(! (otherData == ptr)); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); { // create another object: @@ -220,8 +220,8 @@ void tst_QSharedPointer::basics() // otherData is deleted here } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); { // create a copy: @@ -237,8 +237,8 @@ void tst_QSharedPointer::basics() QCOMPARE(copy.data(), aData); QVERIFY(copy == aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); { // create a weak reference: @@ -269,8 +269,8 @@ void tst_QSharedPointer::basics() QVERIFY(strong == ptr); QCOMPARE(strong.data(), aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); // aData is deleted here } @@ -555,15 +555,15 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QWeakPointer derivedptr = qWeakPointerCast(baseptr); QVERIFY(baseptr == derivedptr); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QWeakPointer weakptr = baseptr; @@ -571,16 +571,16 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QSharedPointer derivedptr = baseptr.staticCast(); QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); } class OtherObject: public QObject @@ -955,8 +955,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QWeakPointer weakptr = baseptr; @@ -965,8 +965,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -974,8 +974,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); } void tst_QSharedPointer::dynamicCastDifferentPointers() @@ -990,8 +990,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QWeakPointer weakptr = baseptr; @@ -1000,8 +1000,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -1009,8 +1009,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { Stuffing *nakedptr = dynamic_cast(baseptr.data()); @@ -1035,8 +1035,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QWeakPointer weakptr = baseptr; @@ -1045,8 +1045,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -1054,8 +1054,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); } void tst_QSharedPointer::dynamicCastFailure() @@ -1067,15 +1067,15 @@ void tst_QSharedPointer::dynamicCastFailure() QSharedPointer derivedptr = qSharedPointerDynamicCast(baseptr); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref), 1); - QCOMPARE(int(refCountData(baseptr)->strongref), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); } #endif @@ -1371,8 +1371,8 @@ void tst_QSharedPointer::creating() QCOMPARE(Data::destructorCounter, 1); // valgrind will complain here if something happened to the pointer - QVERIFY(d->weakref == 1); - QVERIFY(d->strongref == 0); + QVERIFY(d->weakref.load() == 1); + QVERIFY(d->strongref.load() == 0); } check(); -- cgit v1.2.3