Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Avoid leaking `TerminalPanel`, which would in turn leak `Project`
Antonio Scandurrab8539373aa18
diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rsindex 82d7208ef88..32bad620ba0 100644--- a/crates/terminal_view/src/terminal_panel.rs+++ b/crates/terminal_view/src/terminal_panel.rs@@ -53,7 +53,7 @@ pub struct TerminalPanel {impl TerminalPanel {fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {- let terminal_panel = cx.view().clone();+ let terminal_panel = cx.view().downgrade();let pane = cx.new_view(|cx| {let mut pane = Pane::new(workspace.weak_handle(),@@ -77,14 +77,17 @@ impl TerminalPanel {pane.set_can_navigate(false, cx);pane.display_nav_history_buttons(false);pane.set_render_tab_bar_buttons(cx, move |pane, cx| {+ let terminal_panel = terminal_panel.clone();h_stack().gap_2().child(IconButton::new("plus", Icon::Plus).icon_size(IconSize::Small)- .on_click(cx.listener_for(&terminal_panel, |terminal_panel, _, cx| {- terminal_panel.add_terminal(None, cx);- }))+ .on_click(move |_, cx| {+ terminal_panel+ .update(cx, |panel, cx| panel.add_terminal(None, cx))+ .log_err();+ }).tooltip(|cx| Tooltip::text("New Terminal", cx)),).child({