From b58c2c65d11319a9c5ff42693d6a483822f36c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 Feb 2022 16:11:06 +0100 Subject: 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. Fixes: QTBUG-100518 Change-Id: I9bb1a75b17e5f0f50205b757fdb673218d7fb5e0 Reviewed-by: Timur Pocheptsov (cherry picked from commit 242e35e774f07a8a3b561acc658cdfeba4c20752) Reviewed-by: Qt Cherry-pick Bot --- src/gui/platform/darwin/qapplekeymapper.mm | 53 +++++++++++++++--------------- 1 file 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 QAppleKeyMapper::possibleKeys(const QKeyEvent *event) const -#else +#else // iOS + // Keyboard keys (non-modifiers) -API_AVAILABLE(ios(13.4)) static QHash uiKitKeys = { +API_AVAILABLE(ios(13.4)) Qt::Key QAppleKeyMapper::fromUIKitKey(NSString *keyCode) +{ + static QHash 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; -- cgit v1.2.3