From 2c743bc0cb96aa58aa88af8c14cff1b78692e606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Tue, 27 Feb 2024 10:21:12 +0200 Subject: [PATCH] Prevent re-replacing state in setGeometry Do not allow replacing a state again if it is already being replaced. Cleaned up from the patch provided in QTBUG-121126. Fixes: QTBUG-121126 Pick-to: 6.6 Change-Id: Icca932b0e5cccd2f39ac18f29d8f7707887d147f Reviewed-by: Richard Moe Gustavsen (cherry picked from commit f429f12a7fb94ef5970a28eaf0b53aea935044b3) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/widgets/qmainwindowlayout.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 246471dc2cc..3933f2a7cd3 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2230,7 +2230,9 @@ void QMainWindowLayout::applyRestoredState() void QMainWindowLayout::setGeometry(const QRect &_r) { - if (savedState.isValid()) + // Check if the state is valid, and avoid replacing it again if it is currently used + // in applyState + if (savedState.isValid() || (restoredState && isInApplyState)) return; QRect r = _r;