From 480fc8ed52fd7a3117e57decf558ccf6a029522b Mon Sep 17 00:00:00 2001 From: max Date: Wed, 29 May 2024 20:18:53 +0300 Subject: [PATCH] fix borrow logic when sending deferred events --- src/macos/window.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/macos/window.rs b/src/macos/window.rs index f9f19fb..97bc27f 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -447,8 +447,13 @@ impl WindowState { fn send_deferred_events(&self, window_handler: &mut dyn WindowHandler) { let mut window = crate::Window::new(Window { inner: &self.window_inner }); - while let Some(event) = self.deferred_events.borrow_mut().pop_front() { - window_handler.on_event(&mut window, event); + loop { + let next_event = self.deferred_events.borrow_mut().pop_front(); + if let Some(event) = next_event { + window_handler.on_event(&mut window, event); + } else { + break; + } } } }