From ef8b5344e754f1c0f13d17f4f274e9a2a8c01bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 21 Apr 2023 16:27:50 +0200 Subject: Avoid rebuilding the layout before the component is complete isReady() will only return true *after* componentComplete() and *before* destruction is about to happen There is no point in rebuilding the layout when an item is added or removed before the component is ready, because there will be a full layout rebuild as soon as the component is completed. This is a preparation for fixing QTBUG-112691 Change-Id: I6e19578d847c6d4518479bc00f21442333e0fb07 Reviewed-by: Mitch Curtis (cherry picked from commit b9524e4e8d30781413cf200f440c182b9ade52e5) Reviewed-by: Qt Cherry-pick Bot --- src/quicklayouts/qquickstacklayout.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quicklayouts/qquickstacklayout.cpp b/src/quicklayouts/qquickstacklayout.cpp index 5959cc571c..14ebcb434d 100644 --- a/src/quicklayouts/qquickstacklayout.cpp +++ b/src/quicklayouts/qquickstacklayout.cpp @@ -159,6 +159,8 @@ void QQuickStackLayout::componentComplete() void QQuickStackLayout::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) { QQuickLayout::itemChange(change, value); + if (!isReady()) + return; if (change == ItemChildRemovedChange) { QQuickItem *item = value.item; -- cgit v1.2.3