mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
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:
parent
f408521d12
commit
ab10e27424
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue