summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-12-21 20:15:25 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-22 13:20:40 +0100
commitc02ca6752a1b6cb7d427e59594a600de3a46697d (patch)
tree180116b28bb1fd48843225c01efe89db9b16c8ab /src/gui
parent500fd522324a891f4683723a0f69bfda968adb8e (diff)
Fix handling of invalid modifiers in QKeySequence.
When decoding a string don't assume valid modifier strings. If a modifier string is unknown return Qt::Key_unknown instead of skipping the modifier. Currently 'Win+a' is decoded to 'A' but should be Qt::Key_unknown. Change-Id: I1c82031159a8b3c19924a7c9e991bc6b1f90d617 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qkeysequence.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 6ea502b70b..9c0b07c64e 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1259,13 +1259,20 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
// Rational: A modifier will contain the name AND +, so longer than 1, a length of 1 is just
// the remaining part of the shortcut (ei. The 'C' in "Ctrl+C"), so no need to check that.
if (sub.length() > 1) {
+ bool validModifier = false;
for (int j = 0; j < modifs.size(); ++j) {
const QModifKeyName &mkf = modifs.at(j);
if (sub == mkf.name) {
ret |= mkf.qt_key;
+ validModifier = true;
break; // Shortcut, since if we find an other it would/should just be a dup
}
}
+ // We couldn't match the string with a modifier. This is only
+ // possible if this part is the key. The key is never followed by a
+ // '+'. And if the key is '+' the if() above would have skipped it.
+ if (!validModifier)
+ return Qt::Key_unknown;
}
lastI = i + 1;
}