From 9d5183127cff165bf561035fcc8a064dadd3e01b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 24 Apr 2024 12:49:05 +0300 Subject: [PATCH] take alternative sequence into account in QKeySequence::count() and QKeySequence::isEmpty() code that assumes that if QKeySequence::count() returns non-zero or QKeySequence::isEmpty() returns false and the first keys is zero may choke but a key sequence with alternative only (the second key) is absolutely valid now Signed-off-by: Ivailo Monev --- src/gui/kernel/qkeysequence.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 4ae88a949..1adb458b9 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -793,11 +793,14 @@ QKeySequence::~QKeySequence() */ int QKeySequence::count() const { - if (!key1) - return 0; - if (!key2) - return 1; - return 2; + int result = 0; + if (key1 > 0) { + result++; + } + if (key2 > 0) { + result++; + } + return result; } @@ -807,7 +810,7 @@ int QKeySequence::count() const */ bool QKeySequence::isEmpty() const { - return (key1 <= 0); + return (key1 <= 0 && key2 <= 0); }