diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-01-10 22:11:12 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-01-25 08:10:27 +0100 |
commit | 5c3b5efd40b3ab14cc6406a0dca62dfb14b03d46 (patch) | |
tree | 254548bef9f3440f4e28da6ba1fa986b6a488e9f /src/widgets/kernel/qapplication.cpp | |
parent | a11267c5320324cce19496313e2f7f8cdce9d8f7 (diff) |
QMenu: don't crash when another popup is closed when a popup is closed
When closing a popup (submenu) triggers closing another popup (the menu)
programatically it can happen that QApplicationPrivate::popupWidgets is
destroyed. Therefore we have to check if popupWidgets is still valid
after the focus change event was delivered.
Fixes: QTBUG-81222
Change-Id: Ide3a6897e43f389d396a80d8b158f7c8eb04e3aa
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 842c0ea9e6..68f6b72d20 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3762,7 +3762,9 @@ void QApplicationPrivate::closePopup(QWidget *popup) if (QWidget *fw = aw->focusWidget()) fw->setFocus(Qt::PopupFocusReason); - if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard + // can become nullptr due to setFocus() above + if (QApplicationPrivate::popupWidgets && + QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard grabForPopup(aw); } |