aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:22:02 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:22:02 +0300
commit04ea6df18a2b06efd133a4f1b13c2e38817279ae (patch)
tree73b84355c755c6e21f3f66816aeb13e6a16012cd /tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
parent4bb06cfba94bcc9ddf30d968a227d00479d475b7 (diff)
parent1089f8f226d546aef3b032a2f4391e08a3afa48d (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Diffstat (limited to 'tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp')
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index 549aae8c2b..25adf4f31d 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -71,6 +71,7 @@ private slots:
void contextDelete();
void garbageCollection();
void requiredProperties();
+ void deleteInSetInitialState();
private:
QQmlIncubationController controller;
@@ -1213,6 +1214,38 @@ void tst_qqmlincubator::requiredProperties()
}
}
+class DeletingIncubator : public QQmlIncubator
+{
+
+
+ // QQmlIncubator interface
+protected:
+ void statusChanged(Status) override
+ {
+
+ }
+ void setInitialState(QObject *obj) override
+ {
+ delete obj;
+ clear();
+ }
+};
+
+void tst_qqmlincubator::deleteInSetInitialState()
+{
+ QQmlComponent component(&engine, testFileUrl("requiredProperty.qml"));
+ QVERIFY(component.isReady());
+ // forceCompletion immediately after creating an asynchronous object completes it
+ DeletingIncubator incubator;
+ incubator.setInitialProperties({{"requiredProperty", 42}});
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ incubator.forceCompletion(); // no crash
+ QVERIFY(incubator.isNull());
+ QCOMPARE(incubator.object(), nullptr); // object was deleted
+}
+
QTEST_MAIN(tst_qqmlincubator)
#include "tst_qqmlincubator.moc"