Skip to content

Commit 97049a7

Browse files
authored
gpui_macos: Fix deadlock during re-entrant key status changes (zed-industries#51035)
Closes zed-industries#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.
1 parent f1e7f39 commit 97049a7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

crates/gpui_macos/src/window.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,10 +2113,12 @@ extern "C" fn window_did_change_key_status(this: &Object, selector: Sel, _: id)
21132113
// in theory, we're not supposed to invoke this method manually but it balances out
21142114
// the spurious `becomeKeyWindow` event and helps us work around that bug.
21152115
if selector == sel!(windowDidBecomeKey:) && !is_active {
2116+
let native_window = lock.native_window;
2117+
drop(lock);
21162118
unsafe {
2117-
let _: () = msg_send![lock.native_window, resignKeyWindow];
2118-
return;
2119+
let _: () = msg_send![native_window, resignKeyWindow];
21192120
}
2121+
return;
21202122
}
21212123

21222124
let executor = lock.foreground_executor.clone();

0 commit comments

Comments
 (0)