From 34e3bdcb5e99dcae07b8c7749faeb798af21233b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 5 Feb 2024 16:09:30 +0100 Subject: [PATCH] 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 (cherry picked from commit bc7e728fcfd2cfdbff29fa9d1b0f8dae718a0f8c) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/ios/qioswindow.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index c7469315afc..347c7b9df13 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -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];