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
This commit is contained in:
Vlad Zahorodnii 2023-05-26 14:21:16 +03:00
parent 71e8fad1f6
commit 07a6b500c8
2 changed files with 8 additions and 0 deletions

View file

@ -286,6 +286,9 @@ void Workspace::activateWindow(Window *window, bool force)
setActiveWindow(nullptr); setActiveWindow(nullptr);
return; return;
} }
if (window->isDeleted()) {
return;
}
raiseWindow(window); raiseWindow(window);
if (!window->isOnCurrentDesktop()) { if (!window->isOnCurrentDesktop()) {
++block_focus; ++block_focus;

View file

@ -116,6 +116,7 @@ void FocusChain::updateWindowInChain(Window *window, FocusChain::Change change,
void FocusChain::insertWindowIntoChain(Window *window, Chain &chain) void FocusChain::insertWindowIntoChain(Window *window, Chain &chain)
{ {
Q_ASSERT(!window->isDeleted());
if (chain.contains(window)) { if (chain.contains(window)) {
return; return;
} }
@ -130,6 +131,7 @@ void FocusChain::insertWindowIntoChain(Window *window, Chain &chain)
void FocusChain::moveAfterWindow(Window *window, Window *reference) void FocusChain::moveAfterWindow(Window *window, Window *reference)
{ {
Q_ASSERT(!window->isDeleted());
if (!window->wantsTabFocus()) { if (!window->wantsTabFocus()) {
return; return;
} }
@ -147,6 +149,7 @@ void FocusChain::moveAfterWindow(Window *window, Window *reference)
void FocusChain::moveAfterWindowInChain(Window *window, Window *reference, Chain &chain) void FocusChain::moveAfterWindowInChain(Window *window, Window *reference, Chain &chain)
{ {
Q_ASSERT(!window->isDeleted());
if (!chain.contains(reference)) { if (!chain.contains(reference)) {
return; return;
} }
@ -211,12 +214,14 @@ Window *FocusChain::nextForDesktop(Window *reference, VirtualDesktop *desktop) c
void FocusChain::makeFirstInChain(Window *window, Chain &chain) void FocusChain::makeFirstInChain(Window *window, Chain &chain)
{ {
Q_ASSERT(!window->isDeleted());
chain.removeAll(window); chain.removeAll(window);
chain.append(window); chain.append(window);
} }
void FocusChain::makeLastInChain(Window *window, Chain &chain) void FocusChain::makeLastInChain(Window *window, Chain &chain)
{ {
Q_ASSERT(!window->isDeleted());
chain.removeAll(window); chain.removeAll(window);
chain.prepend(window); chain.prepend(window);
} }