diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-27 04:39:27 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-27 04:39:27 (GMT) |
commit | b590c65a82ec6fe085d6d609bf342e2c18b8e6c9 (patch) | |
tree | 18e7d05be25c0a769e12a626108cc2ea8a82edc4 /tests | |
parent | 2af9bc37a5955e8e1da2c3ba03fa0be763e2ae5e (diff) | |
download | Qt-b590c65a82ec6fe085d6d609bf342e2c18b8e6c9.zip Qt-b590c65a82ec6fe085d6d609bf342e2c18b8e6c9.tar.gz Qt-b590c65a82ec6fe085d6d609bf342e2c18b8e6c9.tar.bz2 |
Alias cleanup testcase
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qmllanguage/data/alias.7.qml | 14 | ||||
-rw-r--r-- | tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp | 27 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/alias.7.qml b/tests/auto/declarative/qmllanguage/data/alias.7.qml new file mode 100644 index 0000000..d3cf5fe --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/alias.7.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Object { + property Object object + property alias aliasedObject: target.object + + object: Object { + id: target + + property Object object + object: Object {} + } +} + diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 5ef1a7d..2746e98 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -695,6 +695,33 @@ void tst_qmllanguage::aliasProperties() QCOMPARE(object->property("a").toInt(), 1923); } + + // Ptr Alias Cleanup - check that aliases to ptr types return 0 + // if the object aliased to is removed + { + QmlComponent component(&engine, TEST_FILE("alias.7.qml")); + VERIFY_ERRORS(0); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *object1 = qvariant_cast<QObject *>(object->property("object")); + QVERIFY(object1 != 0); + QObject *object2 = qvariant_cast<QObject *>(object1->property("object")); + QVERIFY(object2 != 0); + + QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject")); + QVERIFY(alias == object2); + + delete object1; + + QObject *alias2 = object; // "Random" start value + int status = -1; + void *a[] = { &alias2, 0, &status }; + QMetaObject::metacall(object, QMetaObject::ReadProperty, + object->metaObject()->indexOfProperty("aliasedObject"), a); + QVERIFY(alias2 == 0); + } } // Test that the root element in a composite type can be a Component |