aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmllanguage/data/listContainingDeleted.qml36
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp20
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/listContainingDeleted.qml b/tests/auto/qml/qqmllanguage/data/listContainingDeleted.qml
new file mode 100644
index 0000000000..efd273ddc6
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/listContainingDeleted.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.12
+
+Item {
+ width: 1024
+ height: 800
+
+ property Component a: Component {
+ id: a
+ Item {
+ property list<QtObject> myList: [
+ QtObject {
+ property bool enabled: true
+ }
+ ]
+ }
+ }
+ Component {
+ id: b
+ Item {
+ property list<QtObject> myList
+
+ function test() {
+ for (var i = 0; i < myList.length; ++i)
+ console.log(i, "==", myList[i].enabled)
+ }
+ }
+ }
+ property Item instance
+ function doAssign(o) {
+ instance = b.createObject(null, {myList: o.myList})
+ }
+ function use() {
+ instance.test()
+ }
+
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 87468c329c..d7ef9999d0 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -303,6 +303,8 @@ private slots:
void typeWrapperToVariant();
+ void listContainingDeletedObject();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -5100,6 +5102,24 @@ void tst_qqmllanguage::typeWrapperToVariant()
QVERIFY(target);
}
+void tst_qqmllanguage::listContainingDeletedObject()
+{
+ QQmlEngine engine;
+ auto url = testFileUrl("listContainingDeleted.qml");
+ const QString message = url.toString() + ":24: TypeError: Cannot read property 'enabled' of null";
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, message.toUtf8().data());
+ QQmlComponent comp(&engine, url);
+ QScopedPointer<QObject> root(comp.create());
+ QVERIFY(root);
+
+ auto cmp = root->property("a").value<QQmlComponent*>();
+ auto o = cmp->create();
+
+ QMetaObject::invokeMethod(root.get(), "doAssign", Q_ARG(QVariant, QVariant::fromValue(o)));
+ delete o;
+ QMetaObject::invokeMethod(root.get(), "use");
+
+}
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"