From f12746c4b7446e42656008352177b9f27300b54f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 21 Apr 2023 16:23:47 +0200 Subject: [PATCH] Avoid double borrow of view in ProjectPanel drag and drop Co-Authored-By: Nathan Sobo --- crates/project_panel/src/project_panel.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 094e1ce0ba..c70ffdd4e1 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1156,7 +1156,6 @@ impl ProjectPanel { theme: &theme::ProjectPanel, cx: &mut ViewContext, ) -> Element { - let this = cx.handle().downgrade(); let kind = details.kind; let path = details.path.clone(); let padding = theme.container.padding.left + details.depth as f32 * theme.indent_width; @@ -1231,21 +1230,17 @@ impl ProjectPanel { }); } }) - .on_move(move |_, _, cx| { + .on_move(move |_, this, cx| { if cx .global::>() .currently_dragged::(cx.window_id()) .is_some() { - if let Some(this) = this.upgrade(cx) { - this.update(cx, |this, _| { - this.dragged_entry_destination = if matches!(kind, EntryKind::File(_)) { - path.parent().map(|parent| Arc::from(parent)) - } else { - Some(path.clone()) - }; - }) - } + this.dragged_entry_destination = if matches!(kind, EntryKind::File(_)) { + path.parent().map(|parent| Arc::from(parent)) + } else { + Some(path.clone()) + }; } }) .as_draggable(entry_id, {