summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/qmllanguage/data/alias.7.qml14
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp27
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