Fix segfault when dropping MacWindow (#9267)

This avoids calling `window.setDelegate(nil)` when the window was
already closed.

Release Notes:

- Fixed a segfault that could show up when closing windows.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Thorsten Ball 2024-03-13 10:41:25 +01:00 committed by GitHub
parent 3c28282108
commit 754df9356d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -695,10 +695,11 @@ impl Drop for MacWindow {
this.renderer.destroy();
let window = this.native_window;
this.display_link.take();
unsafe {
this.native_window.setDelegate_(nil);
}
if !this.native_window_was_closed {
unsafe {
this.native_window.setDelegate_(nil);
}
this.executor
.spawn(async move {
unsafe {