From 8f07015af8909fb9d211317e13e4fd8d31ae9f9a Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Sat, 9 Sep 2023 11:20:56 +0300 Subject: [PATCH] QWindow: avoid extra window resize on changing min/max sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends e7477e8934ab38722f5589914d08b3f15e870109. Do not call QWindow::resize() on changing min/max sizes if bounded window size has not changed. Otherwise it may unexpectedly reset window's state on some platforms, like Windows and Linux. Fixes: QTBUG-115699 Pick-to: 6.5 Change-Id: I217ca3fd854a1f41d6df312e3258734d1d3bce45 Reviewed-by: Tor Arne Vestbø Reviewed-by: Volker Hilsheimer (cherry picked from commit 7efc0f6f1994a06359deb859fd73126d576df226) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 1e30e57baf2..7750c70ba1e 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -597,7 +597,10 @@ void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, // resize window if current size is outside of min and max limits if (minimumSize.width() <= maximumSize.width() || minimumSize.height() <= maximumSize.height()) { - q->resize(q->geometry().size().expandedTo(minimumSize).boundedTo(maximumSize)); + const QSize currentSize = q->size(); + const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize); + if (currentSize != boundedSize) + q->resize(boundedSize); } }