iOS: Remove QUIView from superview on QIOSWindow destruction

Unlike on macOS, our UIViews are children of a QIOSDesktopManagerView
that we use to do window management, so we need to remove the view
from its superview, even if represents a top level QWindow.

The only exception is top level foreign windows, which are used to
represent a native UIView for the purpose of containing a Qt view
hierarchy within. As we don't know anything about the foreign view's
superview hiearchy we shouldn't touch it.

Pick-to: 6.6
Fixes: QTBUG-120369
Change-Id: I6a43bb0a4e72d0d1525a7cc33d572ea7477215b3
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit bc7e728fcfd2cfdbff29fa9d1b0f8dae718a0f8c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-02-05 16:09:30 +01:00 committed by Qt Cherry-pick Bot
parent 27625a33c5
commit 34e3bdcb5e

View File

@ -92,11 +92,12 @@ QIOSWindow::~QIOSWindow()
clearAccessibleCache();
quiview_cast(m_view).platformWindow = 0;
quiview_cast(m_view).platformWindow = nullptr;
// Remove from superview only if we have a Qt window parent,
// as we don't want to affect window container foreign windows.
if (QPlatformWindow::parent())
// Remove from superview, unless we're a foreign window without a
// Qt window parent, in which case the foreign window is used as
// a window container for a Qt UI hierarchy inside a native UI.
if (!(isForeignWindow() && !QPlatformWindow::parent()))
[m_view removeFromSuperview];
[m_view release];