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>
bb10
Vladimir Belyavsky 2023-09-09 11:37:25 +03:00
parent 9c0def81e4
commit b0ba5c78ee
1 changed files with 10 additions and 9 deletions

View File

@ -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());