From 97049a76baaf2299be73fafa06910ccf060e7589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Soares?= <37777652+Dnreikronos@users.noreply.github.com> Date: Tue, 17 Mar 2026 05:50:54 -0300 Subject: [PATCH] gpui_macos: Fix deadlock during re-entrant key status changes (#51035) Closes #50151 Before you mark this PR as ready for review, make sure that you have: - [ ] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - Fixed a deadlock that froze the entire app when opening a new window from a PopUp window or switching focus between multiple windows on macOS. --- crates/gpui_macos/src/window.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs index b783a4d083131fac70095d22718796ef761adee3..002c4719f768d698b5c8b599f039579cfe78640c 100644 --- a/crates/gpui_macos/src/window.rs +++ b/crates/gpui_macos/src/window.rs @@ -2113,10 +2113,12 @@ extern "C" fn window_did_change_key_status(this: &Object, selector: Sel, _: id) // in theory, we're not supposed to invoke this method manually but it balances out // the spurious `becomeKeyWindow` event and helps us work around that bug. if selector == sel!(windowDidBecomeKey:) && !is_active { + let native_window = lock.native_window; + drop(lock); unsafe { - let _: () = msg_send![lock.native_window, resignKeyWindow]; - return; + let _: () = msg_send![native_window, resignKeyWindow]; } + return; } let executor = lock.foreground_executor.clone();