From 7b3fc6ee3f0ef45776a7c8fd044820b909ac2b25 Mon Sep 17 00:00:00 2001 From: Ted Steen Date: Fri, 8 Sep 2023 14:04:41 +0300 Subject: [PATCH] small fixes --- .../examples/pure_glow_sdl2_resize_fix.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/egui_glow/examples/pure_glow_sdl2_resize_fix.rs b/crates/egui_glow/examples/pure_glow_sdl2_resize_fix.rs index 6f4ee0096d3..b80242bb6f6 100644 --- a/crates/egui_glow/examples/pure_glow_sdl2_resize_fix.rs +++ b/crates/egui_glow/examples/pure_glow_sdl2_resize_fix.rs @@ -43,7 +43,7 @@ fn main() { let mut name = "Ted"; let mut age = 41; - let handle_events = std::sync::Arc::new(std::sync::Mutex::new( + let run_egui = std::sync::Arc::new(std::sync::Mutex::new( |event: Option| { let mut quit_clicked: bool = false; egui_glow.run(&window, clipboard, |egui_ctx| { @@ -98,12 +98,8 @@ fn main() { }, )); - let try_handle = |event: Option| -> bool { - if let Ok(handle) = &mut handle_events.try_lock() { - handle(event) - } else { - true - } + let handle = |event: Option| -> bool { + run_egui.lock().map_or(true, |mut handle| handle(event)) }; //Note: this is a workaround for https://stackoverflow.com/a/40693139 @@ -114,12 +110,12 @@ fn main() { .. } = event { - try_handle(Some(event)); + handle(Some(event)); }; }); 'mainloop: loop { - if !try_handle(events_loop.wait_event_timeout(5)) { + if !handle(events_loop.wait_event_timeout(5)) { break 'mainloop; } }