QKeySequence: replace an array end marker by static size calculation
This improves code generation, since the compiler statically knows the number of loop iterations. But it also fixes a compile-error on Clang with a following change of the name field from char* to char[]. Change-Id: I7ef18adf3cb9b34cd1b7235cb35cf26b7e349d92 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
c1804bb5c1
commit
6a35c6d491
|
|
@ -687,8 +687,8 @@ static const struct {
|
|||
{ Qt::Key_TouchpadOn, QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
|
||||
{ Qt::Key_TouchpadOff, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
|
||||
|
||||
/*!
|
||||
\enum QKeySequence::StandardKey
|
||||
|
|
@ -1172,7 +1172,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
|
|||
for (int tran = 0; tran < 2; ++tran) {
|
||||
if (!nativeText)
|
||||
++tran;
|
||||
for (int i = 0; keyname[i].name; ++i) {
|
||||
for (int i = 0; i < numKeyNames; ++i) {
|
||||
QString keyName(tran == 0
|
||||
? QCoreApplication::translate("QShortcut", keyname[i].name)
|
||||
: QString::fromLatin1(keyname[i].name));
|
||||
|
|
@ -1311,7 +1311,7 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma
|
|||
#if defined(Q_OS_MACX)
|
||||
NonSymbol:
|
||||
#endif
|
||||
while (keyname[i].name) {
|
||||
while (i < numKeyNames) {
|
||||
if (key == keyname[i].key) {
|
||||
p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name)
|
||||
: QString::fromLatin1(keyname[i].name);
|
||||
|
|
@ -1323,7 +1323,7 @@ NonSymbol:
|
|||
// fall back on the unicode representation of it...
|
||||
// Or else characters like Qt::Key_aring may not get displayed
|
||||
// (Really depends on you locale)
|
||||
if (!keyname[i].name) {
|
||||
if (i >= numKeyNames) {
|
||||
if (!QChar::requiresSurrogates(key)) {
|
||||
p = QChar(ushort(key)).toUpper();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue