Attempting to continue rebase

This commit is contained in:
Mikayla Maki
2022-07-20 10:04:08 -07:00
parent 4a483618be
commit 150d2ff53f
6 changed files with 227 additions and 184 deletions
+4 -22
View File
@@ -1781,21 +1781,6 @@ impl MutableAppContext {
})
}
pub fn try_add_model<T, F>(&mut self, build_model: F) -> Result<ModelHandle<T>>
where
T: Entity,
F: FnOnce(&mut ModelContext<T>) -> Result<T>,
{
self.update(|this| {
let model_id = post_inc(&mut this.next_entity_id);
let handle = ModelHandle::new(model_id, &this.cx.ref_counts);
let mut cx = ModelContext::new(this, model_id);
let model = build_model(&mut cx)?;
this.cx.models.insert(model_id, Box::new(model));
Ok(handle)
})
}
pub fn add_window<T, F>(
&mut self,
window_options: WindowOptions,
@@ -1970,13 +1955,10 @@ impl MutableAppContext {
for model_id in dropped_models {
self.subscriptions.lock().remove(&model_id);
self.observations.lock().remove(&model_id);
//Model handles and IDs may have been created to instantiate a model without
//finishing successfully (`try_add_model()`)
if let Some(mut model) = self.cx.models.remove(&model_id) {
model.release(self);
self.pending_effects
.push_back(Effect::ModelRelease { model_id, model });
}
let mut model = self.cx.models.remove(&model_id).unwrap();
model.release(self);
self.pending_effects
.push_back(Effect::ModelRelease { model_id, model });
}
for (window_id, view_id) in dropped_views {