mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Avoid double borrow of views on up
and up_out
in DragAndDrop
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
5b40641fde
commit
31e906d068
3 changed files with 9 additions and 5 deletions
|
@ -209,7 +209,7 @@ impl<V: View> DragAndDrop<V> {
|
|||
)
|
||||
.with_cursor_style(CursorStyle::Arrow)
|
||||
.on_up(MouseButton::Left, |_, _, cx| {
|
||||
cx.defer(|_, cx| {
|
||||
cx.window_context().defer(|cx| {
|
||||
cx.update_global::<Self, _, _>(|this, cx| {
|
||||
this.finish_dragging(cx)
|
||||
});
|
||||
|
@ -217,7 +217,7 @@ impl<V: View> DragAndDrop<V> {
|
|||
cx.propagate_event();
|
||||
})
|
||||
.on_up_out(MouseButton::Left, |_, _, cx| {
|
||||
cx.defer(|_, cx| {
|
||||
cx.window_context().defer(|cx| {
|
||||
cx.update_global::<Self, _, _>(|this, cx| {
|
||||
this.finish_dragging(cx)
|
||||
});
|
||||
|
@ -244,14 +244,14 @@ impl<V: View> DragAndDrop<V> {
|
|||
.boxed()
|
||||
})
|
||||
.on_up(MouseButton::Left, |_, _, cx| {
|
||||
cx.defer(|_, cx| {
|
||||
cx.window_context().defer(|cx| {
|
||||
cx.update_global::<Self, _, _>(|this, _| {
|
||||
this.currently_dragged = None;
|
||||
});
|
||||
});
|
||||
})
|
||||
.on_up_out(MouseButton::Left, |_, _, cx| {
|
||||
cx.defer(|_, cx| {
|
||||
cx.window_context().defer(|cx| {
|
||||
cx.update_global::<Self, _, _>(|this, _| {
|
||||
this.currently_dragged = None;
|
||||
});
|
||||
|
|
|
@ -2954,6 +2954,10 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn window_context(&mut self) -> &mut WindowContext<'a, 'b> {
|
||||
&mut self.window_context
|
||||
}
|
||||
|
||||
pub fn handle(&self) -> ViewHandle<V> {
|
||||
ViewHandle::new(
|
||||
self.window_id,
|
||||
|
|
|
@ -174,7 +174,7 @@ impl UpdateView for WindowContext<'_, '_> {
|
|||
&mut cx,
|
||||
)
|
||||
})
|
||||
.unwrap()
|
||||
.expect("view is already on the stack")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue