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>
This commit is contained in:
Tor Arne Vestbø 2022-02-07 16:11:06 +01:00
parent 851143eff1
commit 242e35e774

View File

@ -631,9 +631,12 @@ 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 },
@ -657,10 +660,8 @@ API_AVAILABLE(ios(13.4)) static QHash<NSString *, Qt::Key> uiKitKeys = {
{ 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;