Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix panic due to re-entrantly reading `Workspace`
Antonio Scandurra3763b985e3be
diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex 8d3b10d38e4..ed77b26672f 100644--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@ -134,9 +134,12 @@ impl View for CollabTitlebarItem {}impl CollabTitlebarItem {- pub fn new(workspace: &ViewHandle<Workspace>, cx: &mut ViewContext<Self>) -> Self {+ pub fn new(+ workspace: &ViewHandle<Workspace>,+ user_store: ModelHandle<UserStore>,+ cx: &mut ViewContext<Self>,+ ) -> Self {let active_call = ActiveCall::global(cx);- let user_store = workspace.read(cx).user_store().clone();let mut subscriptions = Vec::new();subscriptions.push(cx.observe(workspace, |_, _, cx| cx.notify()));subscriptions.push(cx.observe(&active_call, |this, _, cx| this.active_call_changed(cx)));diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 40c30f7560e..8126e788db1 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -302,7 +302,9 @@ pub fn initialize_workspace(cx.emit(workspace::Event::PaneAdded(workspace.active_pane().clone()));cx.emit(workspace::Event::PaneAdded(workspace.dock_pane().clone()));- let collab_titlebar_item = cx.add_view(|cx| CollabTitlebarItem::new(&workspace_handle, cx));+ let collab_titlebar_item = cx.add_view(|cx| {+ CollabTitlebarItem::new(&workspace_handle, app_state.user_store.clone(), cx)+ });workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);let project_panel = ProjectPanel::new(workspace.project().clone(), cx);