aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-01-11 14:44:14 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-01-15 09:35:44 +0100
commit4f8041b01445fd4eec0beb133719645d00d0b2ac (patch)
tree69fc40ad29629403280eaf7bf74ff2023804dccb /tests
parent6bccba43c932c8d1370bc03f17ea3082aa6d3ca8 (diff)
QuickLayouts: fix crash when layout width depends on parent width
Some tricky cases of setting layout width based on parent layout width were leading to infinite recursive loop of layout size calculation (see the attached example in the related Jira task). Initially the QQuickGridLayoutBase::rearrange() method already had a recurse check, but it seemed to happen too late, so that the recursive calls kept happening from the ensureLayoutItemsUpdated() calls. This commit moves the recursion check up, so that it's actually executed before we have a chance to get to the next level of recursion. Pick-to: 5.15 6.0 Fixes: QTBUG-87253 Change-Id: I473ee219e7b5b13547e33ebbd3a6d884de2c7d45 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index 85fe54eca6..87e0a01df2 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -1233,5 +1233,42 @@ Item {
// DO NOT CRASH due to stack overflow (or loop endlessly due to updatePolish()/polish() loop)
}
+
+ Component {
+ id: layout_dependentWidth_QTBUG_87253_Component
+
+ RowLayout {
+ anchors.fill: parent;
+
+ RowLayout {
+ spacing: 10
+
+ Text {
+ id: btnOPE
+ text: qsTr("Ok")
+ Layout.fillWidth: true
+ Layout.preferredWidth: (parent.width - 20) / 2
+ }
+
+ Text {
+ id: btnSeeChanged
+ text: qsTr("Not Ok");
+ Layout.fillWidth: true
+ Layout.preferredWidth: (parent.width - 20) / 2
+ }
+ }
+ }
+ }
+
+ function test_dependentWidth_QTBUG_87253()
+ {
+ var warningMsg = new RegExp("Qt Quick Layouts: Detected recursive rearrange. "
+ + "Aborting after two iterations.")
+ for (var i = 0; i < 10; ++i) {
+ ignoreWarning(warningMsg)
+ }
+ var layout = createTemporaryObject(layout_dependentWidth_QTBUG_87253_Component, container)
+ waitForRendering(layout)
+ }
}
}