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);
return;
}
if (window->isDeleted()) {
return;
}
raiseWindow(window);
if (!window->isOnCurrentDesktop()) {
++block_focus;

View file

@ -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);
}