mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Avoid leaking TerminalPanel
, which would in turn leak Project
This commit is contained in:
parent
cf03ea2da9
commit
b8539373aa
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user