From ad45dcb40b888613e723741240ff9df65fb9931c Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 11 Oct 2023 16:44:51 +0100 Subject: [PATCH] x11window: Sync xcb_sync_destroy_alarm to lifetime of the window being alive Recent-ish changes meant that the X11 window is kept alive whilst an effect may be using the window. This changes the lifetime of the sync alarm. This is problematic in the case of an XWayland crash, we can assume whilst an X11 client is valid the X11 connection is also valid, but if a close animation is used the connection might not be valid when the destructor is called. --- src/x11window.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/x11window.cpp b/src/x11window.cpp index 0571d43b4b..4179a93e01 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -360,9 +360,7 @@ X11Window::~X11Window() ::kill(m_killHelperPID, SIGTERM); m_killHelperPID = 0; } - if (m_syncRequest.alarm != XCB_NONE) { - xcb_sync_destroy_alarm(kwinApp()->x11Connection(), m_syncRequest.alarm); - } + Q_ASSERT(!isInteractiveMoveResize()); Q_ASSERT(!check_active_modal); } @@ -458,7 +456,10 @@ void X11Window::releaseWindow(bool on_shutdown) unblockGeometryUpdates(); // Don't use GeometryUpdatesBlocker, it would now set the geometry ungrabXServer(); } - + if (m_syncRequest.alarm != XCB_NONE) { + xcb_sync_destroy_alarm(kwinApp()->x11Connection(), m_syncRequest.alarm); + m_syncRequest.alarm = XCB_NONE; + } unblockCompositing(); unref(); } @@ -504,6 +505,10 @@ void X11Window::destroyWindow() m_frame.reset(); unblockGeometryUpdates(); // Don't use GeometryUpdatesBlocker, it would now set the geometry } + if (m_syncRequest.alarm != XCB_NONE) { + xcb_sync_destroy_alarm(kwinApp()->x11Connection(), m_syncRequest.alarm); + m_syncRequest.alarm = XCB_NONE; + } unblockCompositing(); unref();