From 1523548d3e50f6c61bcb1493db4b1d4cbd8ef441 Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Thu, 25 May 2017 00:11:32 +1000 Subject: [PATCH] wayland: Reset the `intterupted` flag before breaking from run_forever This is important for any code that re-enters `run_forever` after some previous interrupt. --- src/platform/linux/wayland/event_loop.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platform/linux/wayland/event_loop.rs b/src/platform/linux/wayland/event_loop.rs index 48b81bd4..d21597b7 100644 --- a/src/platform/linux/wayland/event_loop.rs +++ b/src/platform/linux/wayland/event_loop.rs @@ -193,7 +193,13 @@ impl EventsLoop { let static_cb = unsafe { ::std::mem::transmute(Box::new(callback) as Box) }; let old_cb = unsafe { self.sink.lock().unwrap().set_callback(static_cb) }; - while !self.interrupted.load(::std::sync::atomic::Ordering::Relaxed) { + loop { + // If `interrupt` was called, break from the loop after resetting the flag. + if self.interrupted.load(::std::sync::atomic::Ordering::Relaxed) { + self.interrupted.store(false, ::std::sync::atomic::Ordering::Relaxed); + break; + } + self.ctxt.dispatch(); evq_guard.dispatch_pending().expect("Wayland connection unexpectedly lost"); let ids_guard = self.decorated_ids.lock().unwrap();