aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickloader
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-05-04 11:09:13 +0800
committerWang Chuan <ouchuanm@outlook.com>2020-05-05 15:22:14 +0800
commita135f3d6c3202b37eda0f1e94292f795f9e575ca (patch)
treec7a7960fe4da5e4740b5cac773078b720c46254d /tests/auto/quick/qquickloader
parentc1ae217a52ace4b955577bf0aaf1c4c8afb8b81b (diff)
QQuickLoader: prevent clearing initial properties after active = true
After commit b6d88c73, we implement the method [disposeInitialPropertyValues] and clear the cache of initial properties actually. Since we also call this method after source loaded, it will cause loss of initial properties after active = true. Fixes: QTBUG-83895 Change-Id: Iaa500fff14dcaad79a9e68dcbac9f65fa8720456 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Diffstat (limited to 'tests/auto/quick/qquickloader')
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.12.qml20
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp5
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.12.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.12.qml
new file mode 100644
index 0000000000..940730b307
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.12.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property int i: 0
+
+ Loader {
+ id: loader
+ objectName: "loader"
+ active: false
+ }
+
+ Component.onCompleted: {
+ loader.setSource("CacheClearTest.qml", {i: 12})
+ loader.active = true
+ loader.active = false
+ loader.active = true
+ root.i = loader.item.i // should be 12
+ }
+}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index 91d0bcab2e..552393491d 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -698,6 +698,11 @@ void tst_QQuickLoader::initialPropertyValues_data()
<< QStringList()
<< (QStringList() << "oldi" << "i")
<< (QVariantList() << 12 << 42);
+
+ QTest::newRow("ensure initial properties aren't disposed after active = true") << testFileUrl("initialPropertyValues.12.qml")
+ << QStringList()
+ << (QStringList() << "i")
+ << (QVariantList() << 12);
}
void tst_QQuickLoader::initialPropertyValues()