summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2011-11-22 14:45:35 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-10 16:11:48 +0100
commit6f0f9f69288925ef423c542ef5eb7302a5431867 (patch)
treea0ded9966183fb45b7868d25350affa2259f29a1 /tests
parenta6ae75f92a8628c727a9c5a9961fa91c583c008e (diff)
Remove QMetaObject guards and deprecate QPointer.
QWeakPointer is superior and preferred. Remove QMetaObject::addGuard(), QMetaObject::changeGuard(), QMetaObject::removeGuard(), and QObjectPrivate::clearGuards(). Implement QPointer using QWeakPointer<T> instead. This changes the behavior of QPointer in 2 ways: - During destruction of a QWidget. Previously, the destructor of QWidget would reset all QPointers so that they would return zero when destroying children. Update tst_QPointer to account for this change. - When constructing a QSharedPointer to take ownership of an object after a QPointer is already tracking the object. Previously, the shared pointer construction would not be affected by the QPointer, but now that QPointer is implemented using QWeakPoiner, constructing the QSharedPointer will cause an abort(). Fix tst_QSharedPointer by removing the use of QPointer in the objectCast() test. These behavior changes are documented in the QPointer class documentation and in the changes file. Change-Id: I92d0276219c076ece7bcb60f6e1b9120ce4f5747 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp4
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp2
2 files changed, 2 insertions, 4 deletions
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index fed98ec86a..c3888022e6 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -241,8 +241,8 @@ public:
ChildWidget::~ChildWidget()
{
- QCOMPARE(static_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0));
- QCOMPARE(qobject_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0));
+ QCOMPARE(static_cast<QWidget *>(guardedPointer), parentWidget());
+ QCOMPARE(qobject_cast<QWidget *>(guardedPointer), parentWidget());
}
class DerivedChild;
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index 7eb1bd2dee..649842f946 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -767,7 +767,6 @@ void tst_QSharedPointer::objectCast()
{
OtherObject *data = new OtherObject;
- QPointer<OtherObject> qptr = data;
QSharedPointer<OtherObject> ptr = QSharedPointer<OtherObject>(data);
QWeakPointer<QObject> weakptr = ptr;
@@ -788,7 +787,6 @@ void tst_QSharedPointer::objectCast()
// drop the reference:
ptr.clear();
QVERIFY(ptr.isNull());
- QVERIFY(qptr.isNull());
QVERIFY(weakptr.toStrongRef().isNull());
// verify that the object casts fail without crash