If decodestring can't translate the string return Qt::Key_unknown.
authorDavid Faure <faure@kde.org>
Tue, 3 Jan 2012 12:34:49 +0000 (13:34 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 10 Jan 2012 01:02:29 +0000 (02:02 +0100)
Change-Id: Ie082b326e944a28b4e29984a527e3841a05b32f6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/gui/kernel/qkeysequence.cpp
tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp

index 4f6eba2..986701b 100644 (file)
@@ -1316,6 +1316,9 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
             if (found)
                 break;
         }
+        // We couldn't translate the key.
+        if (!found)
+            return Qt::Key_unknown;
     }
     return ret;
 }
index e5820e1..fcc30a7 100644 (file)
@@ -537,6 +537,9 @@ void tst_QKeySequence::parseString_data()
     QTest::newRow("Win+A") << "Win+a" <<  QKeySequence(Qt::Key_unknown);
     QTest::newRow("4+3=2") << "4+3=2" <<  QKeySequence(Qt::Key_unknown);
     QTest::newRow("Super+Meta+A") << "Super+Meta+A" << QKeySequence(Qt::Key_unknown);
+    QTest::newRow("Meta+Trolls") << "Meta+Trolls" << QKeySequence(Qt::Key_unknown);
+    QTest::newRow("Alabama") << "Alabama" << QKeySequence(Qt::Key_unknown);
+    QTest::newRow("Simon+G") << "Simon+G" << QKeySequence(Qt::Key_unknown);
 }
 
 void tst_QKeySequence::parseString()
@@ -559,6 +562,9 @@ void tst_QKeySequence::fromString()
     QFETCH(QString, neutralString);
     QFETCH(QString, platformString);
 
+    if (strSequence == "Ctrly") // Key_Unknown gives empty string
+        return;
+
     QKeySequence ks1(strSequence);
     QKeySequence ks2 = QKeySequence::fromString(ks1.toString());
     QKeySequence ks3 = QKeySequence::fromString(neutralString, QKeySequence::PortableText);