From 01f96b1764d0339aca2b7f2de4cef6b97047cb7b Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 23 Oct 2021 14:15:28 +0200 Subject: Don't fire shortcut if the action only lives in an unreachable submenu Menus can be represented by a menu action, and if that menu action has been hidden or disabled, then the submenu is not accessible from the parent menu or menu bar to which it was added. Don't walk the menu action chain further when checking whether the shortcut should trigger. Note that this is unrelated to the menu being visible or not; we obviously want to trigger shortcuts for actions that only live in a menu that has not been shown, otherwise the shortcut would be rather pointless. Pick-to: 6.2 Fixes: QTBUG-25743 Change-Id: I48735e17352989bbc84a72263e4828f519b78095 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qshortcut_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qshortcut_widgets.cpp b/src/widgets/kernel/qshortcut_widgets.cpp index 9e64376fce..8beb4ce5d6 100644 --- a/src/widgets/kernel/qshortcut_widgets.cpp +++ b/src/widgets/kernel/qshortcut_widgets.cpp @@ -307,7 +307,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge continue; #endif QAction *a = menu->menuAction(); - if (correctActionContext(context, a, active_window)) + if (a->isVisible() && a->isEnabled() && correctActionContext(context, a, active_window)) return true; } else #endif -- cgit v1.2.3