aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/platform/qquickplatformmenuitem.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-10-08 16:20:22 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-10-08 18:43:24 +0200
commit746358e855613de5401f5be867365188a19e4800 (patch)
treeec5f7f0309bcbaff53142f4a69926c8655e0b2bc /src/imports/platform/qquickplatformmenuitem.cpp
parente1d2073ddbd81e926640babe94e6d64076ce8eaa (diff)
Only add a shortcut if the sequence is not empty
If the sequence is empty then reset m_shortcutId to -1 so it does not have a shortcut attached to it. Change-Id: I16945950145d9d3ca7da73e998b28d64997501d0 Pick-to: 5.15 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/platform/qquickplatformmenuitem.cpp')
-rw-r--r--src/imports/platform/qquickplatformmenuitem.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
index 11cf98b4..9595a7cc 100644
--- a/src/imports/platform/qquickplatformmenuitem.cpp
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -518,8 +518,12 @@ void QQuickPlatformMenuItem::setShortcut(const QVariant& shortcut)
sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
else
sequence = QKeySequence::fromString(m_shortcut.toString());
- m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence,
- Qt::WindowShortcut, QQuickShortcutContext::matcher);
+ if (!sequence.isEmpty()) {
+ m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence,
+ Qt::WindowShortcut, QQuickShortcutContext::matcher);
+ } else {
+ m_shortcutId = -1;
+ }
#endif
emit shortcutChanged();
}