From 51e9340abba4e97a548514156f8c78c2c2f43978 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 7 May 2022 10:38:11 +0300 Subject: [PATCH] Remove a Workspace::findAbstractClient() overload Workspace::findAbstractClient(QUuid) overload is used only by the windows krunner plugin. This change fixes a potential null dereferencing and removes the findAbstractClient() overload in favor of a more generic findToplevel() overload. --- src/plugins/krunner-integration/windowsrunnerinterface.cpp | 7 +++++-- src/workspace.cpp | 6 ------ src/workspace.h | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/plugins/krunner-integration/windowsrunnerinterface.cpp b/src/plugins/krunner-integration/windowsrunnerinterface.cpp index 3514ed702e..0d8397e616 100644 --- a/src/plugins/krunner-integration/windowsrunnerinterface.cpp +++ b/src/plugins/krunner-integration/windowsrunnerinterface.cpp @@ -218,8 +218,11 @@ void WindowsRunner::Run(const QString &id, const QString &actionId) return; } - const auto uuid = QUuid::fromString(objectId); - const auto window = workspace()->findAbstractClient(uuid); + const auto window = workspace()->findToplevel(QUuid::fromString(objectId)); + if (!window || !window->isClient()) { + return; + } + switch (action) { case ActivateAction: workspace()->activateWindow(window); diff --git a/src/workspace.cpp b/src/workspace.cpp index fcff444d92..b1d4c0edda 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -1790,12 +1790,6 @@ Window *Workspace::findAbstractClient(std::function func) return nullptr; } -Window *Workspace::findAbstractClient(const QUuid &internalId) const -{ - auto t = findToplevel(internalId); - return t && t->isClient() ? t : nullptr; -} - Unmanaged *Workspace::findUnmanaged(std::function func) const { return Window::findInList(m_unmanaged, func); diff --git a/src/workspace.h b/src/workspace.h index d61b4de3c4..4df5ebad4d 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -103,7 +103,6 @@ public: */ X11Window *findClient(std::function func) const; Window *findAbstractClient(std::function func) const; - Window *findAbstractClient(const QUuid &internalId) const; /** * @brief Finds the Client matching the given match @p predicate for the given window. *