From b545a6359bd7a34ccb7683b871ccd4e1f197ae47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 12 May 2017 13:53:55 +0200 Subject: macOS: Don't create NSWindow for embedded views An embedded view does not have a QCocoaWindow parent, but that doesn't mean it's a top level. Improved debug logging to make issues related to this code easier to spot in the future. Change-Id: I15b5acdd8d7112600618465a3b65b64fddc306f7 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b85fb97f67..5ff5d01a99 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -291,6 +291,8 @@ static void qt_closePopups() - (void)closeAndRelease { + qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self; + [self close]; if (self.helper.grabbingMouse) { @@ -361,6 +363,8 @@ static void qt_closePopups() - (void)closeAndRelease { + qCDebug(lcQpaCocoaWindow) << "closeAndRelease" << self; + [self.helper detachFromPlatformWindow]; [self close]; [self release]; @@ -1584,7 +1588,7 @@ void QCocoaWindow::recreateWindowIfNeeded() if (isChildNSWindow() != shouldBeChildNSWindow) recreateReason |= ChildNSWindowChanged; - const bool shouldBeContentView = !parentWindow || shouldBeChildNSWindow; + const bool shouldBeContentView = (!parentWindow && !m_viewIsEmbedded) || shouldBeChildNSWindow; if (isContentView() != shouldBeContentView) recreateReason |= ContentViewChanged; @@ -1601,7 +1605,7 @@ void QCocoaWindow::recreateWindowIfNeeded() return; } - qCDebug(lcQpaCocoaWindow) << "Recreating NSWindow due to" << recreateReason; + qCDebug(lcQpaCocoaWindow) << "Reconfiguring NSWindow due to" << recreateReason; QCocoaWindow *parentCocoaWindow = static_cast(parentWindow); @@ -1616,6 +1620,7 @@ void QCocoaWindow::recreateWindowIfNeeded() // Remove current window (if any) if ((isContentView() && !shouldBeContentView) || (recreateReason & PanelChanged)) { + qCDebug(lcQpaCocoaWindow) << "Getting rid of existing window" << m_nsWindow; [m_nsWindow closeAndRelease]; if (isChildNSWindow()) [m_view.window.parentWindow removeChildWindow:m_view.window]; @@ -1642,6 +1647,7 @@ void QCocoaWindow::recreateWindowIfNeeded() // Move view to new NSWindow if needed if (m_nsWindow.contentView != m_view) { + qCDebug(lcQpaCocoaWindow) << "Ensuring that view is content view for" << m_nsWindow; [m_view setPostsFrameChangedNotifications:NO]; [m_view retain]; if (m_view.superview) // m_view comes from another NSWindow @@ -1723,6 +1729,8 @@ void QCocoaWindow::requestActivateWindow() QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel) { + qCDebug(lcQpaCocoaWindow) << "createNSWindow" << shouldBeChildNSWindow << shouldBePanel; + QMacAutoReleasePool pool; QRect rect = geometry(); -- cgit v1.2.3