diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-01-27 18:40:12 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-02-05 15:52:36 +0100 |
commit | cdeed3f2ad5c59cfd5b6542033fd8f39567a3890 (patch) | |
tree | 17c7a50ee6317d94df572d13bb6b14cf3d406b44 /src/plugins/platforms | |
parent | 38c6e5ebbd0d4d9f956420a02fc17b952cf5818b (diff) |
macOS: Don't assume NSEvent charactersByApplyingModifiers: produces character
In cases where the keyboard layout doesn't have a mapping for a given
event and modifier combination the result will be an empty string.
Fixes: QTBUG-90683
Change-Id: Ice06241f0ae71a19cde041410818decc312bc630
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 7c85a45fde5dd3f84eb033261ccb0d54ee72d30c)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoakeymapper.mm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index 6c378d73b4..9a7b53d025 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -488,8 +488,11 @@ const QCocoaKeyMapper::KeyMap &QCocoaKeyMapper::keyMapForKey(VirtualKeyCode virt // compare the results to Cocoa. auto cocoaModifiers = toCocoaModifiers(qtModifiers); auto *charactersWithModifiers = [NSApp.currentEvent charactersByApplyingModifiers:cocoaModifiers]; - Q_ASSERT(charactersWithModifiers && charactersWithModifiers.length > 0); - auto cocoaUnicodeKey = QChar([charactersWithModifiers characterAtIndex:0]); + + QChar cocoaUnicodeKey; + if (charactersWithModifiers.length > 0) + cocoaUnicodeKey = QChar([charactersWithModifiers characterAtIndex:0]); + if (cocoaUnicodeKey != carbonUnicodeKey) { qCWarning(lcQpaKeyMapper) << "Mismatch between Cocoa" << cocoaUnicodeKey << "and Carbon" << carbonUnicodeKey << "for virtual key" << virtualKey |