aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-11-17 12:12:57 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-11-17 20:59:24 +0100
commita1c1ad11ce6f4a415cefc583cfab41336ecf71e3 (patch)
treee552ec08455f29fe37c3866f3fd1b7456f1ab48b /tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
parentc9380aa42805cf55736dc87c87149d912282c0ae (diff)
Instantiator: Do not load items when inactive
Instantiator would react to model changes even when inactive, causing instances to be errorneously created. We simply skip doing anything when inactive, as setting the Instantiator to active later will trigger a full regenaration anyway. Pick-to: 6.2 5.15 Fixes: QTBUG-86453 Fixes: QTBUG-88331 Change-Id: Ia5fd916bbd591d5fc72c550424b1a53a142c2fa8 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp')
-rw-r--r--tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
index dc0365c5cf..4c6c84a9d2 100644
--- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
+++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
@@ -50,6 +50,7 @@ private slots:
void createMultiple();
void stringModel();
void activeProperty();
+ void activeModelChangeInteraction();
void intModelChange();
void createAndRemove();
@@ -161,6 +162,26 @@ void tst_qqmlinstantiator::activeProperty()
QCOMPARE(object->property("idx").toInt(), 0);
}
+void tst_qqmlinstantiator::activeModelChangeInteraction()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("activeModelChangeInteraction.qml"));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(root);
+
+ // If the instantiator is inactive, a model change does not lead to items being loaded
+ bool ok = false;
+ int count = root->property("instanceCount").toInt(&ok);
+ QVERIFY(ok);
+ QCOMPARE(count, 0);
+
+ // When turning the instantiator active, it will however reflect the model
+ root->setProperty("active", true);
+ count = root->property("instanceCount").toInt(&ok);
+ QVERIFY(ok);
+ QCOMPARE(count, 3);
+}
+
void tst_qqmlinstantiator::intModelChange()
{
QQmlEngine engine;