From 76ad563b45d6f0d931e6f4a41dd0ecee7c33de29 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 5 May 2022 15:52:46 +0200 Subject: [PATCH] Fix memory leak of `ProjectPanel` Co-Authored-By: Nathan Sobo --- crates/project_panel/src/project_panel.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index b88e14f2de..61c97f281d 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -161,7 +161,7 @@ impl ProjectPanel { this }); cx.subscribe(&project_panel, { - let project_panel = project_panel.clone(); + let project_panel = project_panel.downgrade(); move |workspace, _, event, cx| match event { &Event::OpenedEntry { entry_id, @@ -180,7 +180,9 @@ impl ProjectPanel { ) .detach_and_log_err(cx); if !focus_opened_item { - cx.focus(&project_panel); + if let Some(project_panel) = project_panel.upgrade(cx) { + cx.focus(&project_panel); + } } } }