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 <timur.pocheptsov@qt.io>
(cherry picked from commit 6c36e21bec1197e933ee1fbe14bd18936544d32a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-05-08 15:26:50 +02:00 committed by Qt Cherry-pick Bot
parent bb51347266
commit d43c9b0246
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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 <tst_foreignwindow.moc>