From 727afae4ff8c8a077e481250a3a651c66024d30d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 11 Apr 2023 10:58:01 -0700 Subject: [PATCH] Fix unit tests after fixing gpui model drop semantics co-authored-by: Antonio Scandurra --- crates/auto_update/src/auto_update.rs | 4 ++-- crates/client/src/client.rs | 8 +++++--- crates/editor/src/blink_manager.rs | 9 +++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index 9075e4df1a..a12a5dd3a9 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -63,10 +63,10 @@ pub fn init(http_client: Arc, server_url: String, cx: &mut AppCo cx.observe_global::(move |updater, cx| { if cx.global::().auto_update { if update_subscription.is_none() { - *(&mut update_subscription) = Some(updater.start_polling(cx)) + update_subscription = Some(updater.start_polling(cx)) } } else { - (&mut update_subscription).take(); + update_subscription.take(); } }) .detach(); diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index ce808cd08d..5a00f27ddf 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1649,11 +1649,13 @@ mod tests { }, ); drop(subscription1); - let _subscription2 = - client.add_message_handler(model, move |_, _: TypedEnvelope, _, _| { + let _subscription2 = client.add_message_handler( + model.clone(), + move |_, _: TypedEnvelope, _, _| { done_tx2.try_send(()).unwrap(); async { Ok(()) } - }); + }, + ); server.send(proto::Ping {}); done_rx2.next().await.unwrap(); } diff --git a/crates/editor/src/blink_manager.rs b/crates/editor/src/blink_manager.rs index 9651182bd8..409b6f9b03 100644 --- a/crates/editor/src/blink_manager.rs +++ b/crates/editor/src/blink_manager.rs @@ -15,12 +15,9 @@ pub struct BlinkManager { impl BlinkManager { pub fn new(blink_interval: Duration, cx: &mut ModelContext) -> Self { - let weak_handle = cx.weak_handle(); - cx.observe_global::(move |_, cx| { - if let Some(this) = weak_handle.upgrade(cx) { - // Make sure we blink the cursors if the setting is re-enabled - this.update(cx, |this, cx| this.blink_cursors(this.blink_epoch, cx)); - } + cx.observe_global::(move |this, cx| { + // Make sure we blink the cursors if the setting is re-enabled + this.blink_cursors(this.blink_epoch, cx) }) .detach();