From 29c0620a5852a427f182a189c9a68a92131229b8 Mon Sep 17 00:00:00 2001 From: Christian Meissl Date: Mon, 28 Jun 2021 15:38:54 +0200 Subject: [PATCH] test if xwayland is already shutting down on client_destroy --- src/xwayland/xserver.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index cb21546..1188419 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -295,7 +295,12 @@ impl Inner { fn client_destroy(map: &::wayland_server::UserDataMap) { let inner = map.get::>>>().unwrap(); - inner.borrow_mut().shutdown(); + // If we are unable to take a lock we are most likely called during + // a shutdown. This will definitely be the case when the compositor exits + // and the XWayland instance is dropped. + if let Ok(mut guard) = inner.try_borrow_mut() { + guard.shutdown(); + } } fn xwayland_ready(inner: &Rc>>) { @@ -322,7 +327,7 @@ fn xwayland_ready(inner: &Rc>>) { ::std::env::set_var("DISPLAY", format!(":{}", instance.display_lock.display())); // signal the WM - info!(guard.log, "XWayland is ready, signaling the WM."); + info!(guard.log, "XWayland is ready on DISPLAY \":{}\", signaling the WM.", instance.display_lock.display()); // send error occurs if the user dropped the channel... We cannot do much except ignore. let _ = guard.sender.send(XWaylandEvent::Ready { connection: instance.wm_fd.take().unwrap(), // This is a bug if None