fix view leak and add view count

This commit is contained in:
iris committed 2025-08-24 22:13:02 -04:00
1 parent 74d01d14d4
commit 44a8b1cbeb
7 files changed
+41 -18

No files matched your search

+5 -1
View File
@@ -13,6 +13,7 @@ struct State {
region: UiRegion,
children: Vec<Id>,
parent: Option<Id>,
textures: Vec<TextureHandle>,
// TODO: there's probably a better way but idc at this point
id: Option<Id>,
}
@@ -59,6 +60,7 @@ impl<'a, Ctx> Painter<'a, Ctx> {
children: Vec::new(),
parent: None,
id: None,
textures: Vec::new(),
},
}
}
@@ -109,6 +111,7 @@ impl<'a, Ctx> Painter<'a, Ctx> {
children: Vec::new(),
id: Some(id.duplicate()),
parent: self.state.id.as_ref().map(|i| i.duplicate()),
textures: Vec::new(),
};
// save state
let self_state = std::mem::replace(&mut self.state, child_state);
@@ -129,13 +132,14 @@ impl<'a, Ctx> Painter<'a, Ctx> {
span: start_i..end_i,
children: child_state.children,
parent: child_state.parent,
textures: child_state.textures,
},
self.sensors_map,
);
}
pub fn draw_texture(&mut self, handle: &TextureHandle) {
self.primitives.drawn_textures.push(handle.clone());
self.state.textures.push(handle.clone());
self.write(handle.inner);
}
+1
View File
@@ -273,6 +273,7 @@ pub struct WidgetInstance {
pub span: Range<usize>,
pub children: Vec<Id>,
pub parent: Option<Id>,
pub textures: Vec<TextureHandle>,
}
pub type ActiveWidgets = HashMap<Id, WidgetInstance>;