From c4f23e411a6e16b187456097e928f5e22066b428 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 30 Mar 2021 14:25:47 -0600 Subject: [PATCH] Fix double-borrow when synthesizing drag events --- gpui/src/platform/mac/window.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gpui/src/platform/mac/window.rs b/gpui/src/platform/mac/window.rs index 0ed1abc212..0ae27ec66c 100644 --- a/gpui/src/platform/mac/window.rs +++ b/gpui/src/platform/mac/window.rs @@ -450,11 +450,12 @@ async fn synthetic_drag( loop { Timer::after(Duration::from_millis(16)).await; if let Some(window_state) = window_state.upgrade() { - let mut window_state = window_state.borrow_mut(); - if window_state.synthetic_drag_counter == drag_id { - if let Some(mut callback) = window_state.event_callback.take() { + let mut window_state_borrow = window_state.borrow_mut(); + if window_state_borrow.synthetic_drag_counter == drag_id { + if let Some(mut callback) = window_state_borrow.event_callback.take() { + drop(window_state_borrow); callback(Event::LeftMouseDragged { position }); - window_state.event_callback = Some(callback); + window_state.borrow_mut().event_callback = Some(callback); } } else { break;