From ad980696185711619833799888d3c1afab9c3dd1 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 14 Jun 2024 10:43:58 +0300 Subject: [PATCH] Make Window::closeWindow() noop if the window is already closed The surface handle can be dropped by that time. Also, there is no point to ask the client to close the window again if it's already closed. --- src/internalwindow.cpp | 2 +- src/layershellv1window.cpp | 4 +++- src/x11window.cpp | 3 +++ src/xdgshellwindow.cpp | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/internalwindow.cpp b/src/internalwindow.cpp index 645905af9f..b633bca464 100644 --- a/src/internalwindow.cpp +++ b/src/internalwindow.cpp @@ -172,7 +172,7 @@ QString InternalWindow::windowRole() const void InternalWindow::closeWindow() { - if (m_handle) { + if (!isDeleted()) { m_handle->hide(); } } diff --git a/src/layershellv1window.cpp b/src/layershellv1window.cpp index 1bfa71c70c..eb89652166 100644 --- a/src/layershellv1window.cpp +++ b/src/layershellv1window.cpp @@ -211,7 +211,9 @@ void LayerShellV1Window::destroyWindow() void LayerShellV1Window::closeWindow() { - m_shellSurface->sendClosed(); + if (!isDeleted()) { + m_shellSurface->sendClosed(); + } } Layer LayerShellV1Window::belongsToLayer() const diff --git a/src/x11window.cpp b/src/x11window.cpp index 2cba04b401..1bf96bc9f2 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -2031,6 +2031,9 @@ bool X11Window::isCloseable() const */ void X11Window::closeWindow() { + if (isDeleted()) { + return; + } if (!isCloseable()) { return; } diff --git a/src/xdgshellwindow.cpp b/src/xdgshellwindow.cpp index 4cc3800612..b846c509ca 100644 --- a/src/xdgshellwindow.cpp +++ b/src/xdgshellwindow.cpp @@ -668,6 +668,9 @@ void XdgToplevelWindow::applyWindowRules() void XdgToplevelWindow::closeWindow() { + if (isDeleted()) { + return; + } if (isCloseable()) { sendPing(PingReason::CloseWindow); m_shellSurface->sendClose();