From 9fc2251ec901fb8d918886f06185e345d63bcd5f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 25 Oct 2023 16:33:47 +0200 Subject: [PATCH] On macOS, fix deadlock during nested event loops (e.g. rfd) --- CHANGELOG.md | 1 + src/platform_impl/macos/app_state.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53caaba58d..1a68d11157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Unreleased` header. # Unreleased - On Windows, fix deadlock when accessing the state during `Cursor{Enter,Leave}`. +- On macOS, fix deadlock when entering a nested event loop from an event handler. # 0.29.2 diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index a18ffebd8e..114c124f5e 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -494,9 +494,9 @@ impl AppState { // Return when in callback due to https://github.com/rust-windowing/winit/issues/1779 if panic_info.is_panicking() + || HANDLER.get_in_callback() || !HANDLER.have_callback() || !HANDLER.is_running() - || HANDLER.get_in_callback() { return; } @@ -601,9 +601,9 @@ impl AppState { // XXX: how does it make sense that `get_in_callback()` can ever return `true` here if we're // about to return to the `CFRunLoop` to poll for new events? if panic_info.is_panicking() + || HANDLER.get_in_callback() || !HANDLER.have_callback() || !HANDLER.is_running() - || HANDLER.get_in_callback() { return; }