From 9e6d865882275bf3dbc7f9047d15ed5038a0184f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 11 Apr 2023 10:43:05 +0200 Subject: [PATCH] Prevent already dropped model from being upgraded during `release` --- crates/gpui/src/app.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index bc38b28bba..534f77a349 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -2618,7 +2618,7 @@ impl UpgradeModelHandle for AppContext { &self, handle: &WeakModelHandle, ) -> Option> { - if self.models.contains_key(&handle.model_id) { + if self.ref_counts.lock().is_entity_alive(handle.model_id) { Some(ModelHandle::new(handle.model_id, &self.ref_counts)) } else { None @@ -2626,11 +2626,11 @@ impl UpgradeModelHandle for AppContext { } fn model_handle_is_upgradable(&self, handle: &WeakModelHandle) -> bool { - self.models.contains_key(&handle.model_id) + self.ref_counts.lock().is_entity_alive(handle.model_id) } fn upgrade_any_model_handle(&self, handle: &AnyWeakModelHandle) -> Option { - if self.models.contains_key(&handle.model_id) { + if self.ref_counts.lock().is_entity_alive(handle.model_id) { Some(AnyModelHandle::new( handle.model_id, handle.model_type,