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.
This commit is contained in:
Vlad Zahorodnii 2023-05-26 14:29:53 +03:00
parent 07a6b500c8
commit b42919e875

View file

@ -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