diff options
author | Marc Mutz <[email protected]> | 2024-09-30 17:27:06 +0200 |
---|---|---|
committer | Ahmad Samir <[email protected]> | 2024-10-10 22:31:37 +0300 |
commit | 9ef4c123c39c642357c9e8530d59f32f220a7824 (patch) | |
tree | df2eab7e1b48257bed01b068dad9b12c880f647e /src/gui/platform | |
parent | 4f5b48d4c69527e5f2450694219432e84b2af6df (diff) |
QChar: disable implicit conversions on most ctor arguments
The QChar ctor overload set is a mess, as it allows implicit
conversions from other types. E.g. char32_t is using one of the
int/uint overloads. Ditto wchar_t on Unix.
Disallow implicit conversions by making all¹ ctors templates and
constraining them on just the types we want.
¹ except the (uchar, uchar) one
This also removes the need to maintain the SFINAE-unfriendly =delete'd
char/uchar ctors in QT_NO_CAST_FROM_ASCII builds.
Needed to fix a few QChar(Qt::Key) users in Apple code.
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] QChar
constructors no longer perform implicit conversions. They only accept
the exact types listed in the documentation. A backwards-compatible
fix is to explicitly cast to one of the explicitly-supported argument
types.
[ChangeLog][QtCore][QChar] The constructors no longer perform implicit
conversions. They only accept the exact types listed in the
documentation. A backwards-compatible fix is to cast to one of the
explicitly-supported argument types.
Change-Id: I5db96948b4724e96c6a0ede9a8ff5cae3bfa3280
Reviewed-by: Ahmad Samir <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/gui/platform')
-rw-r--r-- | src/gui/platform/darwin/qapplekeymapper.mm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/platform/darwin/qapplekeymapper.mm b/src/gui/platform/darwin/qapplekeymapper.mm index a36df93d8b9..c3c74539248 100644 --- a/src/gui/platform/darwin/qapplekeymapper.mm +++ b/src/gui/platform/darwin/qapplekeymapper.mm @@ -211,7 +211,7 @@ static int toKeyCode(const QChar &key, int virtualKey, int modifiers) qCDebug(lcQpaKeyMapperKeys, "Mapping key: %d (0x%04x) / vk %d (0x%04x)", key.unicode(), key.unicode(), virtualKey, virtualKey); - if (key == QChar(kClearCharCode) && virtualKey == 0x47) + if (key == char16_t(kClearCharCode) && virtualKey == 0x47) return Qt::Key_Clear; if (key.isDigit()) { @@ -246,11 +246,11 @@ static int toKeyCode(const QChar &key, int virtualKey, int modifiers) } // Check if they belong to key codes in private unicode range - if (key >= QChar(NSUpArrowFunctionKey) && key <= QChar(NSModeSwitchFunctionKey)) { + if (key >= char16_t(NSUpArrowFunctionKey) && key <= char16_t(NSModeSwitchFunctionKey)) { if (auto qtKey = functionKeys.value(key.unicode())) { qCDebug(lcQpaKeyMapperKeys) << "Got" << qtKey; return qtKey; - } else if (key >= QChar(NSF1FunctionKey) && key <= QChar(NSF35FunctionKey)) { + } else if (key >= char16_t(NSF1FunctionKey) && key <= char16_t(NSF35FunctionKey)) { auto functionKey = Qt::Key_F1 + (key.unicode() - NSF1FunctionKey) ; qCDebug(lcQpaKeyMapperKeys) << "Got" << functionKey; return functionKey; @@ -331,9 +331,9 @@ QChar QAppleKeyMapper::toCocoaKey(Qt::Key key) { // Prioritize overloaded keys if (key == Qt::Key_Return) - return QChar(NSCarriageReturnCharacter); + return char16_t(NSCarriageReturnCharacter); if (key == Qt::Key_Backspace) - return QChar(NSBackspaceCharacter); + return char16_t(NSBackspaceCharacter); Q_CONSTINIT static QHash<Qt::Key, char16_t> reverseCocoaKeys; if (reverseCocoaKeys.isEmpty()) { |