From 07a6b500c8837da16a25a3454a0b89c36cf7b814 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 26 May 2023 14:21:16 +0300 Subject: [PATCH] Add closed window checks in some window activation code paths A closed window cannot be activated, so guard relevant code paths to ensure that we don't hit this unexpected case. CCBUG: 438315 --- src/activation.cpp | 3 +++ src/focuschain.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/activation.cpp b/src/activation.cpp index 811ca0b0a1..d6fd5eebdd 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -286,6 +286,9 @@ void Workspace::activateWindow(Window *window, bool force) setActiveWindow(nullptr); return; } + if (window->isDeleted()) { + return; + } raiseWindow(window); if (!window->isOnCurrentDesktop()) { ++block_focus; diff --git a/src/focuschain.cpp b/src/focuschain.cpp index 33b0cb7241..bbdbe080c3 100644 --- a/src/focuschain.cpp +++ b/src/focuschain.cpp @@ -116,6 +116,7 @@ void FocusChain::updateWindowInChain(Window *window, FocusChain::Change change, void FocusChain::insertWindowIntoChain(Window *window, Chain &chain) { + Q_ASSERT(!window->isDeleted()); if (chain.contains(window)) { return; } @@ -130,6 +131,7 @@ void FocusChain::insertWindowIntoChain(Window *window, Chain &chain) void FocusChain::moveAfterWindow(Window *window, Window *reference) { + Q_ASSERT(!window->isDeleted()); if (!window->wantsTabFocus()) { return; } @@ -147,6 +149,7 @@ void FocusChain::moveAfterWindow(Window *window, Window *reference) void FocusChain::moveAfterWindowInChain(Window *window, Window *reference, Chain &chain) { + Q_ASSERT(!window->isDeleted()); if (!chain.contains(reference)) { return; } @@ -211,12 +214,14 @@ Window *FocusChain::nextForDesktop(Window *reference, VirtualDesktop *desktop) c void FocusChain::makeFirstInChain(Window *window, Chain &chain) { + Q_ASSERT(!window->isDeleted()); chain.removeAll(window); chain.append(window); } void FocusChain::makeLastInChain(Window *window, Chain &chain) { + Q_ASSERT(!window->isDeleted()); chain.removeAll(window); chain.prepend(window); }