From 746358e855613de5401f5be867365188a19e4800 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 8 Oct 2020 16:20:22 +0200 Subject: 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 --- src/imports/platform/qquickplatformmenuitem.cpp | 8 ++++++-- 1 file 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(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(); } -- cgit v1.2.3