diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-07 16:11:06 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-09 18:19:57 +0100 |
commit | 242e35e774f07a8a3b561acc658cdfeba4c20752 (patch) | |
tree | c6699c6293f8ce25c5a87afe1300652bcf665b8a /src/gui/platform | |
parent | 851143eff14dd732fea6be10b96c0bfc798cd629 (diff) |
Avoid file-static initialization of symbols that need @availability check
Fixes crash in key mapper on iOS < 13.4, where the symbols are not
available.
Pick-to: 6.2 6.3
Fixes: QTBUG-100518
Change-Id: I9bb1a75b17e5f0f50205b757fdb673218d7fb5e0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/gui/platform')
-rw-r--r-- | src/gui/platform/darwin/qapplekeymapper.mm | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/gui/platform/darwin/qapplekeymapper.mm b/src/gui/platform/darwin/qapplekeymapper.mm index 8011154c0b..98c7378e1f 100644 --- a/src/gui/platform/darwin/qapplekeymapper.mm +++ b/src/gui/platform/darwin/qapplekeymapper.mm @@ -631,36 +631,37 @@ QList<int> QAppleKeyMapper::possibleKeys(const QKeyEvent *event) const -#else +#else // iOS + // Keyboard keys (non-modifiers) -API_AVAILABLE(ios(13.4)) static QHash<NSString *, Qt::Key> uiKitKeys = { +API_AVAILABLE(ios(13.4)) Qt::Key QAppleKeyMapper::fromUIKitKey(NSString *keyCode) +{ + static QHash<NSString *, Qt::Key> uiKitKeys = { #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_13_4) - { UIKeyInputF1, Qt::Key_F1 }, - { UIKeyInputF2, Qt::Key_F2 }, - { UIKeyInputF3, Qt::Key_F3 }, - { UIKeyInputF4, Qt::Key_F4 }, - { UIKeyInputF5, Qt::Key_F5 }, - { UIKeyInputF6, Qt::Key_F6 }, - { UIKeyInputF7, Qt::Key_F7 }, - { UIKeyInputF8, Qt::Key_F8 }, - { UIKeyInputF9, Qt::Key_F9 }, - { UIKeyInputF10, Qt::Key_F10 }, - { UIKeyInputF11, Qt::Key_F11 }, - { UIKeyInputF12, Qt::Key_F12 }, - { UIKeyInputHome, Qt::Key_Home }, - { UIKeyInputEnd, Qt::Key_End }, - { UIKeyInputPageUp, Qt::Key_PageUp }, - { UIKeyInputPageDown, Qt::Key_PageDown }, + { UIKeyInputF1, Qt::Key_F1 }, + { UIKeyInputF2, Qt::Key_F2 }, + { UIKeyInputF3, Qt::Key_F3 }, + { UIKeyInputF4, Qt::Key_F4 }, + { UIKeyInputF5, Qt::Key_F5 }, + { UIKeyInputF6, Qt::Key_F6 }, + { UIKeyInputF7, Qt::Key_F7 }, + { UIKeyInputF8, Qt::Key_F8 }, + { UIKeyInputF9, Qt::Key_F9 }, + { UIKeyInputF10, Qt::Key_F10 }, + { UIKeyInputF11, Qt::Key_F11 }, + { UIKeyInputF12, Qt::Key_F12 }, + { UIKeyInputHome, Qt::Key_Home }, + { UIKeyInputEnd, Qt::Key_End }, + { UIKeyInputPageUp, Qt::Key_PageUp }, + { UIKeyInputPageDown, Qt::Key_PageDown }, #endif - { UIKeyInputEscape, Qt::Key_Escape }, - { UIKeyInputUpArrow, Qt::Key_Up }, - { UIKeyInputDownArrow, Qt::Key_Down }, - { UIKeyInputLeftArrow, Qt::Key_Left }, - { UIKeyInputRightArrow, Qt::Key_Right } -}; + { UIKeyInputEscape, Qt::Key_Escape }, + { UIKeyInputUpArrow, Qt::Key_Up }, + { UIKeyInputDownArrow, Qt::Key_Down }, + { UIKeyInputLeftArrow, Qt::Key_Left }, + { UIKeyInputRightArrow, Qt::Key_Right } + }; -API_AVAILABLE(ios(13.4)) Qt::Key QAppleKeyMapper::fromUIKitKey(NSString *keyCode) -{ if (auto key = uiKitKeys.value(keyCode)) return key; |