From 5c3b5efd40b3ab14cc6406a0dca62dfb14b03d46 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 10 Jan 2020 22:11:12 +0100 Subject: 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 Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qapplication.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets/kernel/qapplication.cpp') 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); } -- cgit v1.2.3