summaryrefslogtreecommitdiffstats
path: root/src/gui/platform
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-15 18:24:59 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-16 19:26:29 +0200
commit99a4419647df14bf81d1837d22c9636957fd6257 (patch)
treedf84a2aa73a439ffeaa0fde48abd6d1adeac8a25 /src/gui/platform
parent9009a36c01a5539d9a4f21242feaab86c90eaf01 (diff)
macOS: Don't treat null-key as potential shortcut key
When mapping virtual keys and modifiers to their corresponding characters via a keyboard layout we may hit combinations that do not produce any characters. This can happen if there's no <key> element defined for the virtual key, or if the output attribute of the element is empty (despite the spec saying there should always be one UTF-16 code point in the output). https://developer.apple.com/library/archive/technotes/tn2056/_index.html When that happens QAppleKeyMapper::keyMapForKey() will map the combination to a null-QChar, resulting in the "key" being 0. We do not want to propagate this back to the QShortcutMap machinery, as QShortcutMap does not validate the keys coming out of QKeyMapper::possibleKeys(). In particular, it doesn't check the isEmpty() or count() of the QKeySequences it creates. And even if it did, QKeySequence itself seems to treat Qt::Key(0) + Qt::SomeModifier as a non-empty sequence, so passing on 0-keys would still give weird bugs. The user-visible result of passing back 0-keys is that QShortcutMap will treat it as a partial match for any incoming key combination (as long as some modifier is pressed that triggers the QShortcutMap machinery), which resulting in eating the key press. This compounded the issue in QTBUG-95471. Regression after fab3dfff7d53d496a31c5d2df972ddacfe861a4d. Task-number: QTBUG-95471 Pick-to: 6.1 6.2 Change-Id: I2e51ec86f4df2a708e1757be827ab74859be3c8b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/platform')
-rw-r--r--src/gui/platform/darwin/qapplekeymapper.mm2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/platform/darwin/qapplekeymapper.mm b/src/gui/platform/darwin/qapplekeymapper.mm
index 738fab3863..29fdae8d7f 100644
--- a/src/gui/platform/darwin/qapplekeymapper.mm
+++ b/src/gui/platform/darwin/qapplekeymapper.mm
@@ -579,6 +579,8 @@ QList<int> QAppleKeyMapper::possibleKeys(const QKeyEvent *event) const
auto keyAfterApplyingModifiers = keyMap[i];
if (keyAfterApplyingModifiers == unmodifiedKey)
continue;
+ if (!keyAfterApplyingModifiers)
+ continue;
// Include key if event modifiers includes, or matches
// perfectly, the current candidate modifiers.