From 60d5b06e2163606d2f9a5e84d1e48038072d5c78 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 25 Jan 2020 10:21:44 +0100 Subject: [PATCH] WindowServer: Tear down WSClientConnection asynchronously If something goes wrong when trying to message a windowing client, we now tear it down *on next event loop* instead of immediately. This avoids having to deal with disconnected windows suddenly disappearing from window lists while looping over them. --- Servers/WindowServer/WSClientConnection.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 114a98ed5d..0b02575837 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -81,7 +81,9 @@ WSClientConnection::~WSClientConnection() void WSClientConnection::die() { - s_connections->remove(client_id()); + deferred_invoke([this](auto&) { + s_connections->remove(client_id()); + }); } void WSClientConnection::notify_about_new_screen_rect(const Rect& rect)