From d43c9b024621d52344cbcd55b86585a09c74a7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 May 2024 15:26:50 +0200 Subject: [PATCH] iOS: Always call setParent during QIOSWindow construction We rely on setParent for parenting top level windows into our desktop manager view, so we can't condition the call on having a parent window, like we do on other platforms. This was a regression from 988039729f55a5e62e32b82c6f29ff7457e91d9d. Fixes: QTBUG-125142 Change-Id: I2884d77db09cba5371ccd77eabda7ce38c0292de Reviewed-by: Timur Pocheptsov (cherry picked from commit 6c36e21bec1197e933ee1fbe14bd18936544d32a) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/ios/qioswindow.mm | 6 ++++-- tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 6b1f6032252..027752248c8 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -55,8 +55,10 @@ QIOSWindow::QIOSWindow(QWindow *window, WId nativeHandle) connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QIOSWindow::applicationStateChanged); - if (QPlatformWindow::parent()) - setParent(QPlatformWindow::parent()); + // Always set parent, even if we don't have a parent window, + // as we use setParent to reparent top levels into our desktop + // manager view. + setParent(QPlatformWindow::parent()); if (!isForeignWindow()) { // Resolve default window geometry in case it was not set before creating the diff --git a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp index 526abd6ea37..fdb1b333efa 100644 --- a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp @@ -172,6 +172,9 @@ void tst_ForeignWindow::destroyWhenParentIsDestroyed() // Reparenting into a window will result in creating it QVERIFY(parentWindow.handle()); + parentWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parentWindow)); + // Destroying the parent window of the foreign window results // in destroying the foreign window as well, as the foreign // window no longer has a parent it can be embedded in. @@ -184,6 +187,9 @@ void tst_ForeignWindow::destroyWhenParentIsDestroyed() foreignWindow->create(); QVERIFY(foreignWindow->handle()); QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId()); + + parentWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parentWindow)); } #include