From 06f9516d3127a4540347255568afa82fe8a22bb3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 18 Aug 2022 14:59:17 +0200 Subject: [PATCH] Fix crash when closing a window while in full-screen mode This commit delays closing the native window to the next tick to avoid borrowing either `WindowState` or `MutableAppContext` twice. --- crates/gpui/src/platform/mac/window.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 83dd9d6e20..aed8bd92b6 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -458,9 +458,15 @@ impl Window { impl Drop for Window { fn drop(&mut self) { - unsafe { - self.0.as_ref().borrow().native_window.close(); - } + let this = self.0.borrow(); + let window = this.native_window; + this.executor + .spawn(async move { + unsafe { + window.close(); + } + }) + .detach(); } }