From 57201e863c2e66362e58191b2cac81f7c61c01d6 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 27 Aug 2023 23:15:27 +0300 Subject: [PATCH] kglobalaccel: correct check for invalid key sequences in keysFromString() function Signed-off-by: Ivailo Monev --- kglobalaccel/component.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kglobalaccel/component.cpp b/kglobalaccel/component.cpp index 8e3ada7e..aeaa0cdd 100644 --- a/kglobalaccel/component.cpp +++ b/kglobalaccel/component.cpp @@ -41,8 +41,9 @@ static QList keysFromString(const QString &str) } const QStringList strList = str.split('\t'); foreach (const QString &s, strList) { - int key = QKeySequence(s)[0]; - if (key != -1) { //sanity check just in case + const int key = QKeySequence(s)[0]; + if (key != 0) { + // sanity check just in case ret.append(key); } } @@ -56,7 +57,7 @@ static QString stringFromKeys(const QList &keys) return QString::fromLatin1("none"); } QString ret; - foreach (int key, keys) { + foreach (const int key, keys) { ret.append(QKeySequence(key).toString()); ret.append('\t'); }