macOS: Handle missing key in QKeySequencePrivate::decodeString()
On macOS we pull out all the modifiers up front, which in the case of incomplete key sequences such as "Meta+Shift+" will result in an empty string as a result. The cross-platform code does not handle that case, so we need to exit early. This fixes an assert in tst_QKeySequence::parseString(). An assert has been added to QKeySequencePrivate::decodeString() to make the assumption about the 'accel' argument explicit. Change-Id: I135e62f9051a8b899202e5fb224b5d3c77bf2062 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
44b6757fe5
commit
30e26d258b
@ -1062,6 +1062,8 @@ int QKeySequence::decodeString(const QString &str)
|
||||
|
||||
int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceFormat format)
|
||||
{
|
||||
Q_ASSERT(!accel.isEmpty());
|
||||
|
||||
int ret = 0;
|
||||
accel = std::move(accel).toLower();
|
||||
bool nativeText = (format == QKeySequence::NativeText);
|
||||
@ -1121,7 +1123,10 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
|
||||
sl = accel;
|
||||
}
|
||||
}
|
||||
if (accel.isEmpty()) // Incomplete, like for "Meta+Shift+"
|
||||
return Qt::Key_unknown;
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
int lastI = 0;
|
||||
while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user