From 8b0df252c7261a0b6087ee89db642f55ef774edf Mon Sep 17 00:00:00 2001 From: Murarth Date: Tue, 18 Feb 2020 14:02:19 -0700 Subject: [PATCH] X11: Fix deadlock when an error occurs during startup --- src/platform_impl/linux/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index dfb18341fd..9411730324 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -584,13 +584,12 @@ impl EventLoop { } pub fn new_x11_any_thread() -> Result, XNotSupported> { - X11_BACKEND - .lock() - .as_ref() - .map(Arc::clone) - .map(x11::EventLoop::new) - .map(EventLoop::X) - .map_err(|err| err.clone()) + let xconn = match X11_BACKEND.lock().as_ref() { + Ok(xconn) => xconn.clone(), + Err(err) => return Err(err.clone()), + }; + + Ok(EventLoop::X(x11::EventLoop::new(xconn))) } #[inline]