macOS: Mark the widget's container as embedded when placed into NSMenuItem
Otherwise we'll end up creating a NSPanel for the QMacNativeWidget which is never closed, even if the backing NSView is moved to a new superview. Ideally this would be based on [NSView viewDidMoveToSuperview] and [NSView viewDidMoveToWindow], with retain/releases of the corresponding NSWindow, but that needs more research, especially as AppKit on macOS 10.13 will always keep a strong reference to the NSWindow. Task-number: QTBUG-63443 Change-Id: I9eec5ea871373d00dedf154600bf7005898cf37a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
ed9340a926
commit
ac35f9c44c
@ -1240,7 +1240,7 @@ void QCocoaWindow::recreateWindowIfNeeded()
|
|||||||
if (m_windowModality != window()->modality())
|
if (m_windowModality != window()->modality())
|
||||||
recreateReason |= WindowModalityChanged;
|
recreateReason |= WindowModalityChanged;
|
||||||
|
|
||||||
const bool shouldBeContentView = !parentWindow && !m_viewIsEmbedded;
|
const bool shouldBeContentView = !parentWindow && !(m_viewIsToBeEmbedded || m_viewIsEmbedded);
|
||||||
if (isContentView() != shouldBeContentView)
|
if (isContentView() != shouldBeContentView)
|
||||||
recreateReason |= ContentViewChanged;
|
recreateReason |= ContentViewChanged;
|
||||||
|
|
||||||
|
@ -135,6 +135,11 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
|
|||||||
containerWindow->setFlags(wf | Qt::SubWindow);
|
containerWindow->setFlags(wf | Qt::SubWindow);
|
||||||
[(NSView *)widget->winId() setAutoresizingMask:NSViewWidthSizable];
|
[(NSView *)widget->winId() setAutoresizingMask:NSViewWidthSizable];
|
||||||
|
|
||||||
|
if (QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("setEmbeddedInForeignView")) {
|
||||||
|
typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded);
|
||||||
|
reinterpret_cast<SetEmbeddedInForeignViewFunction>(function)(containerWindow->handle(), true);
|
||||||
|
}
|
||||||
|
|
||||||
item->setNativeContents((WId)containerView);
|
item->setNativeContents((WId)containerView);
|
||||||
container->show();
|
container->show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user