set geometry property in QXcbWindow after checking minimum size
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Sun, 3 Mar 2024 09:03:16 +0000 (09:03 +0000)
committerSteve Langasek <vorlon@debian.org>
Sun, 3 Mar 2024 09:03:16 +0000 (09:03 +0000)
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=6a3627b6c5aa5109
Last-Update: 2023-01-04

QXcbWindow::create() bound the window's size to windowMinimumSize(),
after its size had been inherited from parent().
QPlatformWindow::setGeometry() was called before that sanity check.

When a fullscreen window is re-mapped from a deactivated screen to the
remaining screen, the call to QPlatformWindow::setGeometry() assigns
an invalid QRect to QPlatformWindowPrivate::rect
The negative int values x2 and/or y2 cause
QXcbBackingStoreImage::flushPixmap to address unmapped memory and
crash.

This patch moves the call to QPlatformWindow::setGeometry() from
before to after bounding to a minimum value. That assures a valid
rectangle to be assigned in all cases.

Gbp-Pq: Name qxcbwindow_set_geometry.diff

src/plugins/platforms/xcb/qxcbwindow.cpp

index bffad0fac58c339d9840a3e26b9c5e0f3e28585a..45bac8ee852e5803d96d9e45f2088c88e04aea71 100644 (file)
@@ -299,11 +299,6 @@ void QXcbWindow::create()
         return;
     }
 
-    QPlatformWindow::setGeometry(rect);
-
-    if (platformScreen != currentScreen)
-        QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen());
-
     const QSize minimumSize = windowMinimumSize();
     if (rect.width() > 0 || rect.height() > 0) {
         rect.setWidth(qBound(1, rect.width(), XCOORD_MAX));
@@ -315,6 +310,11 @@ void QXcbWindow::create()
         rect.setHeight(QHighDpi::toNativePixels(int(defaultWindowHeight), platformScreen->QPlatformScreen::screen()));
     }
 
+    QPlatformWindow::setGeometry(rect);
+
+    if (platformScreen != currentScreen)
+        QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen());
+
     xcb_window_t xcb_parent_id = platformScreen->root();
     if (parent()) {
         xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();