From 7aba1f9691c6b0d08916a2d385d179ba876553a8 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 12 Mar 2026 19:58:57 -0600 Subject: [PATCH] Fix leak detector on HeadlessAppContext (#51442) Closes #ISSUE 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 - [ ] 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: - N/A --- crates/gpui/src/app/headless_app_context.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/gpui/src/app/headless_app_context.rs b/crates/gpui/src/app/headless_app_context.rs index bebade89d9a8417769147e5f64923953e4bc3694..90dc8c8f0c0994e3f118916b2d004f7d90566ea7 100644 --- a/crates/gpui/src/app/headless_app_context.rs +++ b/crates/gpui/src/app/headless_app_context.rs @@ -186,6 +186,14 @@ impl HeadlessAppContext { } } +impl Drop for HeadlessAppContext { + fn drop(&mut self) { + // Shut down the app so windows are closed and entity handles are + // released before the LeakDetector runs. + self.app.borrow_mut().shutdown(); + } +} + impl AppContext for HeadlessAppContext { fn new(&mut self, build_entity: impl FnOnce(&mut Context) -> T) -> Entity { let mut app = self.app.borrow_mut();