macOS: Don't try to create or manage NSWindow of foreign windows

A foreign window is a single NSView, and unlike our QNSView, where we
in addition manage a NSWindow for top level windows we should treat
the foreign window as just an NSView. It's not our place to neither
create nor dispose of any NSWindows attached to the foreign window.

Pick-to: 6.5
Change-Id: I88aa796c679be0489abf4999829d1378ba054bdc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-03-06 13:59:42 +01:00
parent aab71c7bb8
commit b64b0c7947

View File

@ -1435,6 +1435,14 @@ void QCocoaWindow::recreateWindowIfNeeded()
{ {
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (isForeignWindow()) {
// A foreign window is created as such, and can never move between being
// foreign and not, so we don't need to get rid of any existing NSWindows,
// nor create new ones, as a foreign window is a single simple NSView.
qCDebug(lcQpaWindow) << "Skipping NSWindow management for foreign window" << this;
return;
}
QPlatformWindow *parentWindow = QPlatformWindow::parent(); QPlatformWindow *parentWindow = QPlatformWindow::parent();
const bool isEmbeddedView = isEmbedded(); const bool isEmbeddedView = isEmbedded();