mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 03:25:59 +00:00
Avoid leaking TerminalPanel
, which would in turn leak Project
This commit is contained in:
parent
cf03ea2da9
commit
b8539373aa
1 changed files with 7 additions and 4 deletions
|
@ -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 a new issue