From 7886fa8474bb6fc0274ef05f15981bc795125a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 9 Dec 2020 17:43:24 +0100 Subject: macOS: Fix crash when showing parent-less platform menus Pick-to: 6.0 Pick-to: 5.15 Change-Id: I80f02da1621e4088eb040bb16a4db3867b6ad4d7 Reviewed-by: Alexandru Croitor --- src/plugins/platforms/cocoa/qcocoamenu.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/cocoa/qcocoamenu.mm') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 648f900aa5..1a788e5197 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -386,7 +386,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, QCocoaScreen *cocoaScreen = static_cast(screen->handle()); int availableHeight = cocoaScreen->availableGeometry().height(); - const QPoint &globalPos = cocoaWindow->mapToGlobal(pos); + const QPoint globalPos = cocoaWindow ? cocoaWindow->mapToGlobal(pos) : pos; int menuHeight = m_nativeMenu.size.height; if (globalPos.y() + menuHeight > availableHeight) { // Maybe we need to fix the vertical popup position but we don't know the @@ -430,7 +430,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, // The calls above block, and also swallow any mouse release event, // so we need to clear any mouse button that triggered the menu popup. - if (!cocoaWindow->isForeignWindow()) + if (cocoaWindow && !cocoaWindow->isForeignWindow()) [qnsview_cast(view) resetMouseButtons]; } -- cgit v1.2.3