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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-24 12:49:05 +03:00
parent 47f8d408ba
commit 9d5183127c

View file

@ -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);
}