From ab10e27424f550d49b2a6b6314c2edd0e23d2a3a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 6 May 2021 15:18:09 -0600 Subject: [PATCH] Create a pending view handle before creating a view This way, if we create and drop a handle during the creation of a view, we don't drop the view before we have a chance to increment its initial reference count. Co-Authored-By: Max Brunsfeld --- gpui/src/app.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpui/src/app.rs b/gpui/src/app.rs index 9f3087bb1cd13aea74e29a4be471e3dfd10ddfe7..d86f5342f88a9d230951e87316f41694afb08fbc 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -844,6 +844,7 @@ impl MutableAppContext { { let view_id = post_inc(&mut self.next_entity_id); self.pending_flushes += 1; + let handle = ViewHandle::new(window_id, view_id, &self.ctx.ref_counts); let mut ctx = ViewContext::new(self, window_id, view_id); let handle = if let Some(view) = build_view(&mut ctx) { self.ctx.views.insert((window_id, view_id), Box::new(view)); @@ -854,7 +855,7 @@ impl MutableAppContext { .updated .insert(view_id); } - Some(ViewHandle::new(window_id, view_id, &self.ctx.ref_counts)) + Some(handle) } else { None };