From 1a628e82cc2637e1b162e7dbf3f8bf62068fe544 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Mon, 24 Jul 2023 13:57:54 +0200 Subject: [PATCH] Return 0 in QWindow::winId in case of failed platform window creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-114613 Change-Id: I93184d95f8f448ab115570a18cdb720449a0637d Reviewed-by: Tor Arne Vestbø (cherry picked from commit 63824363ab4844816a4ea16a4d315c74ae21344a) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b59c32ac343..1e30e57baf2 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -687,6 +687,7 @@ void QWindow::create() Returns the window's platform id. \note This function will cause the platform window to be created if it is not already. + Returns 0, if the platform window creation failed. For platforms where this id might be useful, the value returned will uniquely represent the window inside the corresponding screen. @@ -700,6 +701,9 @@ WId QWindow::winId() const if (!d->platformWindow) const_cast(this)->create(); + if (!d->platformWindow) + return 0; + return d->platformWindow->winId(); }