From 9999f533291f3964721fa7a4677fc425b0463bb7 Mon Sep 17 00:00:00 2001 From: Murarth Date: Wed, 19 Feb 2020 10:39:00 -0700 Subject: [PATCH] X11: Fix deadlock when an error occurs during startup (#1475) --- 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]