aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSanthosh Kumar <santhosh.kumar.selvaraj@qt.io>2023-03-31 17:44:10 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-14 13:44:30 +0000
commit8b6a4a9235751abcccee745b3317d3eda7ccae1c (patch)
tree2f2a49bce4ebe6ed09bf65ed2143a64ab35b5258 /tests
parent416688e1c8ec927ba26a04d0bf4da18c69488a6a (diff)
Fix stack layout index when loaded asynchronously
Lazy loading of stack layout causes incorrect index value in the attached property for the child items. This is because, attachedProperties are created and updated for the child object, after being added to the stack layout. This patchset triggers childItemsChanged() to reset child objects of stack layout with right index value. Fixes: QTBUG-111902 Change-Id: Iad06d028d0f977189b5da1122904dc754060a609 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit e397e5b43c9a9844e652adf5ef55365e0a40f57b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
index e8d311183e..99713991bd 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml
@@ -724,6 +724,38 @@ Item {
compare(layout.num_onCountChanged, 1)
}
+ // QTBUG-111902
+ Component {
+ id: stackComponent
+ Loader {
+ id: loader
+ asynchronous: true
+ sourceComponent: StackLayout {
+ id: stackLayout
+ Repeater {
+ model: 3
+ Item {
+ required property int index
+ }
+ }
+ }
+ }
+ }
+ function test_loadStackLayoutAsynchronously() {
+ var loaderObj = stackComponent.createObject(container)
+ // Check for loader status to be ready
+ tryCompare(loaderObj, 'status', 1)
+ // Get stack layout object
+ var stackLayoutObj = loaderObj.item
+ // Check repeater index of child object
+ compare(stackLayoutObj.children[0].index, 0)
+ compare(stackLayoutObj.children[1].index, 1)
+ compare(stackLayoutObj.children[2].index, 2)
+ // Check stack layout attached property index
+ compare(stackLayoutObj.children[0].StackLayout.index, 0)
+ compare(stackLayoutObj.children[1].StackLayout.index, 1)
+ compare(stackLayoutObj.children[2].StackLayout.index, 2)
+ }
}
}