diff options
author | Wang Chuan <ouchuanm@outlook.com> | 2020-05-04 11:09:13 +0800 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-11 21:39:36 +0000 |
commit | c57b803e26c3f98b4f22bcc0f1029fb963e92b0e (patch) | |
tree | 46a9099fd4bce97ebb4ed64e6e2005f8240e94b1 /tests | |
parent | 4461cd02d1fdc7f0a7062c49f08657a1c4a3336b (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.
(cherry-picked from commit a135f3d6c3202b37eda0f1e94292f795f9e575ca)
Fixes: QTBUG-83895
Change-Id: Iaa500fff14dcaad79a9e68dcbac9f65fa8720456
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickloader/data/initialPropertyValues.12.qml | 20 | ||||
-rw-r--r-- | tests/auto/quick/qquickloader/tst_qquickloader.cpp | 5 |
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 f4b682f3f4..0f6c811adb 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -700,6 +700,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() |