diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2023-09-09 11:37:25 +0300 |
---|---|---|
committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2023-09-15 20:51:29 +0000 |
commit | b0ba5c78eee0a476f5ab3e55e3bf3b5476e481c4 (patch) | |
tree | de2f2832dd1b5ce79eaf49344f7327eaefe5e548 | |
parent | 9c0def81e4e5f473e6abe4a61c94df51a78beb63 (diff) |
QWindow: bail out early on resize() if size has not changed
On some platforms, like Windows and Linux, calling resize() may
unexpectedly reset window state even when the actual size has not
changed. So, bail out early on QWindow::resize() if new size is the
same.
Task-number: QTBUG-115699
Change-Id: I64ad611044008964b5201951a50f3866e2108b49
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 3c9194cb6e..00d66913e1 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -614,8 +614,7 @@ void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, || minimumSize.height() <= maximumSize.height()) { const QSize currentSize = q->size(); const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize); - if (currentSize != boundedSize) - q->resize(boundedSize); + q->resize(boundedSize); } } @@ -1646,20 +1645,18 @@ void QWindow::setY(int arg) \property QWindow::width \brief the width of the window's geometry */ -void QWindow::setWidth(int arg) +void QWindow::setWidth(int w) { - if (width() != arg) - resize(arg, height()); + resize(w, height()); } /*! \property QWindow::height \brief the height of the window's geometry */ -void QWindow::setHeight(int arg) +void QWindow::setHeight(int h) { - if (height() != arg) - resize(width(), arg); + resize(width(), h); } /*! @@ -1981,12 +1978,16 @@ void QWindow::resize(int w, int h) void QWindow::resize(const QSize &newSize) { Q_D(QWindow); + + const QSize oldSize = size(); + if (newSize == oldSize) + return; + d->positionPolicy = QWindowPrivate::WindowFrameExclusive; if (d->platformWindow) { d->platformWindow->setGeometry( QHighDpi::toNativeWindowGeometry(QRect(position(), newSize), this)); } else { - const QSize oldSize = d->geometry.size(); d->geometry.setSize(newSize); if (newSize.width() != oldSize.width()) emit widthChanged(newSize.width()); |