From cd8fcd90ca6085c8341c278130d76d46d6cc18cd Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Sun, 24 Dec 2023 10:41:22 -0700 Subject: [PATCH] macos: clear `runloop` Option in sync with `count` --- src/platform/macos_iokit/events.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/platform/macos_iokit/events.rs b/src/platform/macos_iokit/events.rs index f0f3444..def21ce 100644 --- a/src/platform/macos_iokit/events.rs +++ b/src/platform/macos_iokit/events.rs @@ -51,11 +51,6 @@ pub(crate) fn add_event_source(source: CFRunLoopSource) -> EventRegistration { runloop.add_source(&source.0, unsafe { kCFRunLoopCommonModes }); tx.send(SendCFRunLoop(runloop)).unwrap(); CFRunLoop::run_current(); - - // Remove the global if we exited the run loop - let mut el = EVENT_LOOP.lock().unwrap(); - let _ = el.runloop.take(); - el.count = 0; info!("event loop thread exited"); }); event_loop.runloop = Some(rx.recv().expect("failed to start run loop thread")); @@ -78,6 +73,7 @@ impl Drop for EventRegistration { if event_loop.count == 0 { runloop.stop(); + event_loop.runloop.take(); } } }