From 9e9f7a482abbfc862c9a5cc292139a36b5f25700 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 11 Jan 2012 16:01:10 +0100 Subject: [PATCH] Don't use RefCount int operations , as those are going away. This cleans use of those operations in the QArrayData stack. Change-Id: I67705fe0a2f8d99ea13739b675021356a5736f83 Reviewed-by: Robin Burchell Reviewed-by: hjk --- src/corelib/tools/qarraydataops.h | 4 +-- .../corelib/tools/qarraydata/tst_qarraydata.cpp | 36 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index a3c372f..8800cff 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -83,7 +83,7 @@ struct QPodArrayOps void destroyAll() // Call from destructors, ONLY! { - Q_ASSERT(this->ref == 0); + Q_ASSERT(this->ref.atomic.load() == 0); // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. @@ -138,7 +138,7 @@ struct QGenericArrayOps // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. - Q_ASSERT(this->ref == 0); + Q_ASSERT(this->ref.atomic.load() == 0); const T *const b = this->begin(); const T *i = this->end(); diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 4d121a8..d1da18d 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -92,25 +92,25 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 1 (owned) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(1) }, 0, 0, 0, 0 }; - QCOMPARE(int(array.ref), 1); + QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(!array.ref.isStatic()); QVERIFY(array.ref.isSharable()); QVERIFY(array.ref.ref()); - QCOMPARE(int(array.ref), 2); + QCOMPARE(array.ref.atomic.load(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(int(array.ref), 1); + QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(array.ref.ref()); - QCOMPARE(int(array.ref), 2); + QCOMPARE(array.ref.atomic.load(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(int(array.ref), 1); + QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(!array.ref.deref()); - QCOMPARE(int(array.ref), 0); + QCOMPARE(array.ref.atomic.load(), 0); // Now would be a good time to free/release allocated data } @@ -119,17 +119,17 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; - QCOMPARE(int(array.ref), 0); + QCOMPARE(array.ref.atomic.load(), 0); QVERIFY(!array.ref.isStatic()); QVERIFY(!array.ref.isSharable()); QVERIFY(!array.ref.ref()); // Reference counting fails, data should be copied - QCOMPARE(int(array.ref), 0); + QCOMPARE(array.ref.atomic.load(), 0); QVERIFY(!array.ref.deref()); - QCOMPARE(int(array.ref), 0); + QCOMPARE(array.ref.atomic.load(), 0); // Free/release data } @@ -138,16 +138,16 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to -1 (static read-only data) QArrayData array = { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, 0 }; - QCOMPARE(int(array.ref), -1); + QCOMPARE(array.ref.atomic.load(), -1); QVERIFY(array.ref.isStatic()); QVERIFY(array.ref.isSharable()); QVERIFY(array.ref.ref()); - QCOMPARE(int(array.ref), -1); + QCOMPARE(array.ref.atomic.load(), -1); QVERIFY(array.ref.deref()); - QCOMPARE(int(array.ref), -1); + QCOMPARE(array.ref.atomic.load(), -1); } } @@ -164,20 +164,20 @@ void tst_QArrayData::sharedNullEmpty() QVERIFY(empty->ref.isSharable()); QVERIFY(empty->ref.isShared()); - QCOMPARE(int(null->ref), -1); - QCOMPARE(int(empty->ref), -1); + QCOMPARE(null->ref.atomic.load(), -1); + QCOMPARE(empty->ref.atomic.load(), -1); QVERIFY(null->ref.ref()); QVERIFY(empty->ref.ref()); - QCOMPARE(int(null->ref), -1); - QCOMPARE(int(empty->ref), -1); + QCOMPARE(null->ref.atomic.load(), -1); + QCOMPARE(empty->ref.atomic.load(), -1); QVERIFY(null->ref.deref()); QVERIFY(empty->ref.deref()); - QCOMPARE(int(null->ref), -1); - QCOMPARE(int(empty->ref), -1); + QCOMPARE(null->ref.atomic.load(), -1); + QCOMPARE(empty->ref.atomic.load(), -1); QVERIFY(null != empty); -- 2.7.4