From 3ca95678f1698c42699847c6d5034a35b5401713 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 22 May 2023 18:57:14 +0200 Subject: [PATCH] Avoid leaking docks when adding panels --- crates/workspace/src/workspace.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 6c7d61fef9625e9a5030ca0505114d37ba981de3..bd50251cf1a56717814e2001f50c863213e6b2e1 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -477,7 +477,7 @@ pub struct Workspace { leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>, database_id: WorkspaceId, app_state: Arc, - _subscriptions: Vec, + subscriptions: Vec, _apply_leader_updates: Task>, _observe_current_user: Task>, pane_history_timestamp: Arc, @@ -683,7 +683,7 @@ impl Workspace { _observe_current_user, _apply_leader_updates, leader_updates_tx, - _subscriptions: subscriptions, + subscriptions, pane_history_timestamp, }; this.project_remote_id_changed(project.read(cx).remote_id(), cx); @@ -846,7 +846,7 @@ impl Workspace { DockPosition::Right => &self.right_dock, }; - cx.subscribe(&panel, { + self.subscriptions.push(cx.subscribe(&panel, { let mut dock = dock.clone(); let mut prev_position = panel.position(cx); move |this, panel, event, cx| { @@ -884,8 +884,7 @@ impl Workspace { cx.notify(); } } - }) - .detach(); + })); dock.update(cx, |dock, cx| dock.add_panel(panel, cx)); }