diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-12-09 17:43:24 +0100 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2021-02-11 09:55:18 +0200 |
commit | d91b3cbd19153f6518debf5abb01292efaeebd2a (patch) | |
tree | 97a394d71ee3d5aac12b1ea3f63f06fadd8e8fd4 | |
parent | b936d5eb3af4ff329bdaf745162ef340abd08df1 (diff) |
macOS: Fix crash when showing parent-less platform menus
Change-Id: I80f02da1621e4088eb040bb16a4db3867b6ad4d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 7886fa8474bb6fc0274ef05f15981bc795125a47)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenu.mm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index da6ddd25da..8e2af2b183 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -377,7 +377,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, QCocoaScreen *cocoaScreen = static_cast<QCocoaScreen *>(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 @@ -421,7 +421,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]; } |