Skip to content

Commit 9c54bd1

Browse files
mrnuggetas-cii
andauthored
macOS: Drop input handler to avoid editor/project not being dropped (#18898)
This fixes the problem of a `Project` sometimes not being dropped when closing the single, last window of Zed. Turns out, it wasn't get dropped for the following reason: 1. `editor::Editor` held a reference to project 2. The macOS `input_handler` on the `Window` held a reference to that `Editor` 3. The AppKit window (and its input handler) get dropped asynchronously (in the code in this diff), after the window is closed. 4. After the window is closed and no `cx.update()` calls are made anymore, `flush_effects` is not called anymore. 5. But `flush_effects` is where we dropped entities that don't have any more references. In short: we dropped `Editor`, which held a reference to `Project`, out of band, `flush_effects` wasn't called anymore, and thus the `Project` wasn't dropped. cc @ConradIrwin @bennetbo since we talked about this. Release Notes: - N/A Co-authored-by: Antonio <antonio@zed.dev>
1 parent 5d5c4b6 commit 9c54bd1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

crates/gpui/src/platform/mac/window.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ impl Drop for MacWindow {
768768
unsafe {
769769
this.native_window.setDelegate_(nil);
770770
}
771+
this.input_handler.take();
771772
this.executor
772773
.spawn(async move {
773774
unsafe {

0 commit comments

Comments
 (0)