Attempting to continue rebase
This commit is contained in:
+4
-22
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user