aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-01-11 14:44:14 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-22 14:39:02 +0000
commit8b9bac7125021b57ffc2edecc8482adafcb0b398 (patch)
treeab163db50f0b17f6c09b57f943f3594f54d7297b /src
parent4a2065318442f5848fffd08fa2cbce9d1290bb33 (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. Fixes: QTBUG-87253 Change-Id: I473ee219e7b5b13547e33ebbd3a6d884de2c7d45 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 4f8041b01445fd4eec0beb133719645d00d0b2ac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index 4df264f264..dbd56b1996 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -470,8 +470,6 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
if (!isReady())
return;
- ensureLayoutItemsUpdated();
-
qCDebug(lcQuickLayouts) << "QQuickGridLayoutBase::rearrange" << d->m_recurRearrangeCounter << this;
const auto refCounter = qScopeGuard([&d] {
--(d->m_recurRearrangeCounter);
@@ -483,6 +481,8 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
return;
}
+ ensureLayoutItemsUpdated();
+
d->m_rearranging = true;
qCDebug(lcQuickLayouts) << objectName() << "QQuickGridLayoutBase::rearrange()" << size;
Qt::LayoutDirection visualDir = effectiveLayoutDirection();