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 <robin+qt@viroteck.net>
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
João Abecasis 2012-01-11 16:01:10 +01:00 committed by Qt by Nokia
parent 301f7b780c
commit 9e9f7a482a
2 changed files with 20 additions and 20 deletions

View File

@ -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();

View File

@ -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);