diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-10-23 14:15:28 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-25 19:53:46 +0000 |
commit | aa6c144082decbc424317d7506ed37ab3c0e9251 (patch) | |
tree | 42376a806d68639ec4e3cdc5406e41207f3216e8 /src | |
parent | 618ef607d6857859540c5d00b9ea5864fd1eb686 (diff) |
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.
Fixes: QTBUG-25743
Change-Id: I48735e17352989bbc84a72263e4828f519b78095
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 01f96b1764d0339aca2b7f2de4cef6b97047cb7b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/kernel/qshortcut_widgets.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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 |