From b42919e875589f643857c7251ca7aa7221bf38f0 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 26 May 2023 14:29:53 +0300 Subject: [PATCH] Add closed window checks in restacking requests If a closed window is restacked, it will be reintroduced to the stack and it will be left dangling, which will eventually result in a crash. --- src/layers.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/layers.cpp b/src/layers.cpp index efa4391356..1c3453a29d 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -293,6 +293,10 @@ void Workspace::lowerWindow(Window *window, bool nogroup) if (!window) { return; } + if (window->isDeleted()) { + qCWarning(KWIN_CORE) << "Workspace::lowerWindow: closed window" << window << "cannot be restacked"; + return; + } window->cancelAutoRaise(); @@ -319,6 +323,10 @@ void Workspace::lowerWindowWithinApplication(Window *window) if (!window) { return; } + if (window->isDeleted()) { + qCWarning(KWIN_CORE) << "Workspace::lowerWindowWithinApplication: closed window" << window << "cannot be restacked"; + return; + } window->cancelAutoRaise(); @@ -349,6 +357,10 @@ void Workspace::raiseWindow(Window *window, bool nogroup) if (!window) { return; } + if (window->isDeleted()) { + qCWarning(KWIN_CORE) << "Workspace::raiseWindow: closed window" << window << "cannot be restacked"; + return; + } window->cancelAutoRaise(); @@ -374,6 +386,10 @@ void Workspace::raiseWindowWithinApplication(Window *window) if (!window) { return; } + if (window->isDeleted()) { + qCWarning(KWIN_CORE) << "Workspace::raiseWindowWithinApplication: closed window" << window << "cannot be restacked"; + return; + } window->cancelAutoRaise(); @@ -427,6 +443,10 @@ void Workspace::lowerWindowRequest(Window *window) void Workspace::restack(Window *window, Window *under, bool force) { + if (window->isDeleted()) { + qCWarning(KWIN_CORE) << "Workspace::restack: closed window" << window << "cannot be restacked"; + return; + } Q_ASSERT(unconstrained_stacking_order.contains(under)); if (!force && !Window::belongToSameApplication(under, window)) { // put in the stacking order below _all_ windows belonging to the active application