commit 1fe860421bd8b4010ae98eb4cec30ae10db4b332 parent ad1a1dd774a628dfa38a329d481618c52a0661f7 Author: William Casarin <jb55@jb55.com> Date: Wed, 30 Nov 2022 11:10:49 -0800 don't panic if we ever fail to lock here Diffstat:
M | src/lib.rs | | | 17 | +++++++++-------- |
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs @@ -34,18 +34,19 @@ struct ExampleRepaintSignal(std::sync::Mutex<winit::event_loop::EventLoopProxy<W impl epi::backend::RepaintSignal for ExampleRepaintSignal { fn request_repaint(&self) { - self.0 - .lock() - .unwrap_or_else(|e| { - panic!( + match self.0.lock() { + Err(e) => { + error!( "Failed to lock guard at {} line {} with error\n{}", file!(), line!(), e - ) - }) - .send_event(WinitEvent::RequestRedraw) - .ok(); + ); + } + Ok(e) => { + let _ = e.send_event(WinitEvent::RequestRedraw); + } + }; } }