check if the caused popup widget is null before qobject_cast<T>()-ing it

fixes crash on FreeBSD

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-10 08:49:42 +03:00
parent a435ce9889
commit f4dc49f06a

View file

@ -445,9 +445,11 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
// Reselect the currently active action in case mouse moved over other menu items when // Reselect the currently active action in case mouse moved over other menu items when
// moving from sub menu action to sub menu (QTBUG-20094). // moving from sub menu action to sub menu (QTBUG-20094).
if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) { if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) { if (causedPopup.widget) {
if (causedPopup.action && menu->d_func()->activeMenu == q) if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); if (causedPopup.action && menu->d_func()->activeMenu == q)
menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
}
} }
return; return;
} }