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 <maxbrunsfeld@gmail.com>
This commit is contained in:
co-authored by
Max Brunsfeld
parent
f408521d12
commit
ab10e27424
+2
-1
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user