From 07551a4487fb01dc2fd6481947f05c6546d9e743 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Thu, 9 Sep 2021 17:23:03 +0200 Subject: [PATCH] Workspace: Better check of registered client shortcuts Do not discard a shortcut immediately when it is already registered in KGlobalAccel, because there could be possible dangling shortcuts if they weren't properly cleaned-up (ex. after a crash). Instead we delay the check for conflicts with other client shortcuts to the second loop, which we know is up to date. BUG: 442215 FIXED-IN: 5.22.80 --- src/useractions.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/useractions.cpp b/src/useractions.cpp index 5ae3774770..9044289974 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -1822,14 +1822,19 @@ bool Workspace::shortcutAvailable(const QKeySequence &cut, AbstractClient* ignor if (ignore && cut == ignore->shortcut()) return true; - if (!KGlobalAccel::getGlobalShortcutsByKey(cut).isEmpty()) { - return false; - } - for (auto it = m_allClients.constBegin(); - it != m_allClients.constEnd(); - ++it) { - if ((*it) != ignore && (*it)->shortcut() == cut) + // Check if the shortcut is already registered + const QList registeredShortcuts = KGlobalAccel::getGlobalShortcutsByKey(cut); + for (const auto shortcut : registeredShortcuts) { + // Only return "not available" if is not a client activation shortcut, as it may be no longer valid + if (!shortcut.uniqueName().startsWith(QStringLiteral("_k_session:"))) { return false; + } + } + // Check now conflicts with activation shortcuts for current clients + for (const auto client : qAsConst(m_allClients)) { + if (client != ignore && client->shortcut() == cut) { + return false; + } } return true; }