Don't refcount window handles
This commit is contained in:
@@ -25,7 +25,6 @@ struct ElementStateRefCount {
|
||||
pub struct RefCounts {
|
||||
entity_counts: HashMap<usize, usize>,
|
||||
element_state_counts: HashMap<ElementStateId, ElementStateRefCount>,
|
||||
dropped_windows: HashSet<usize>,
|
||||
dropped_models: HashSet<usize>,
|
||||
dropped_views: HashSet<(usize, usize)>,
|
||||
dropped_element_states: HashSet<ElementStateId>,
|
||||
@@ -44,18 +43,6 @@ impl RefCounts {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inc_window(&mut self, window_id: usize) {
|
||||
match self.entity_counts.entry(window_id) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
*entry.get_mut() += 1;
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(1);
|
||||
self.dropped_windows.remove(&window_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inc_model(&mut self, model_id: usize) {
|
||||
match self.entity_counts.entry(model_id) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
@@ -98,15 +85,6 @@ impl RefCounts {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dec_window(&mut self, window_id: usize) {
|
||||
let count = self.entity_counts.get_mut(&window_id).unwrap();
|
||||
*count -= 1;
|
||||
if *count == 0 {
|
||||
self.entity_counts.remove(&window_id);
|
||||
self.dropped_windows.insert(window_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dec_model(&mut self, model_id: usize) {
|
||||
let count = self.entity_counts.get_mut(&model_id).unwrap();
|
||||
*count -= 1;
|
||||
|
||||
@@ -157,9 +157,9 @@ impl TestAppContext {
|
||||
.cx
|
||||
.borrow_mut()
|
||||
.add_window(Default::default(), build_root_view);
|
||||
self.simulate_window_activation(Some(window.id()));
|
||||
self.simulate_window_activation(Some(window.window_id()));
|
||||
|
||||
WindowHandle::new(window.id(), self.cx.borrow_mut().ref_counts.clone())
|
||||
WindowHandle::new(window.window_id())
|
||||
}
|
||||
|
||||
pub fn add_view<T, F>(&mut self, window_id: usize, build_view: F) -> ViewHandle<T>
|
||||
|
||||
@@ -1165,7 +1165,7 @@ impl<'a> WindowContext<'a> {
|
||||
let root_view = self.add_view(|cx| build_root_view(cx));
|
||||
self.window.focused_view_id = Some(root_view.id());
|
||||
self.window.root_view = Some(root_view.into_any());
|
||||
WindowHandle::new(self.window_id, self.ref_counts.clone())
|
||||
WindowHandle::new(self.window_id)
|
||||
}
|
||||
|
||||
pub fn add_view<T, F>(&mut self, build_view: F) -> ViewHandle<T>
|
||||
|
||||
Reference in New Issue
Block a user