summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2011-07-05 23:46:19 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-03 07:57:41 +0200
commit5bfeab8749ce6820d55135b81665a7231d3b1504 (patch)
tree152569571114c53d4cdfaa0013307267cb3379a6 /tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
parent5613c9722adee921e16682c0a035f2a7567bd346 (diff)
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 <qt_sanity_bot@ovi.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp')
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp80
1 files changed, 40 insertions, 40 deletions
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<Data *>(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<DerivedData> derivedptr = qWeakPointerCast<DerivedData>(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<Data> weakptr = baseptr;
@@ -571,16 +571,16 @@ void tst_QSharedPointer::upCast()
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(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<DerivedData> derivedptr = baseptr.staticCast<DerivedData>();
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(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<Data *>(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<Data> weakptr = baseptr;
@@ -965,8 +965,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
@@ -974,8 +974,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<Data *>(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<Data> weakptr = baseptr;
@@ -1000,8 +1000,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>();
@@ -1009,8 +1009,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<Stuffing *>(baseptr.data());
@@ -1035,8 +1035,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<Data> weakptr = baseptr;
@@ -1045,8 +1045,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>();
@@ -1054,8 +1054,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(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<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(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<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
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();