fix on_id widget refcount leak (-> memory leak)

This commit is contained in:
iris committed 2025-12-04 02:59:05 -05:00
1 parent 84c460a91f
commit e5d0a7e592
6 files changed
+74 -130

No files matched your search

+2 -26
View File
@@ -3,8 +3,8 @@ use image::DynamicImage;
use crate::{
core::{TextEdit, TextEditCtx},
layout::{
Event, EventFn, EventModule, IdLike, PainterData, PixelRegion, StaticWidgetId,
TextureHandle, Vec2, Widget, WidgetId, WidgetInstance, WidgetLike,
Event, EventFn, EventModule, IdLike, PainterData, PixelRegion, TextureHandle, Vec2, Widget,
WidgetId, WidgetInstance, WidgetLike,
},
util::{HashSet, Id},
};
@@ -30,14 +30,6 @@ impl Ui {
w.add(self)
}
pub fn add_static<W: Widget, Tag>(
&mut self,
w: impl WidgetLike<Tag, Widget = W>,
) -> StaticWidgetId<W> {
let id = w.add(self);
id.into_static()
}
/// useful for debugging
pub fn set_label<W>(&mut self, id: &WidgetId<W>, label: String) {
self.data.widgets.data_mut(&id.id).unwrap().label = label;
@@ -79,7 +71,6 @@ impl Ui {
self.data.widgets.reserve(),
TypeId::of::<W>(),
self.send.clone(),
false,
)
}
@@ -215,21 +206,6 @@ impl<W: Widget> IndexMut<&WidgetId<W>> for Ui {
}
}
impl<W: Widget> Index<StaticWidgetId<W>> for Ui {
type Output = W;
fn index(&self, id: StaticWidgetId<W>) -> &Self::Output {
self.data.widgets.get(&id).unwrap()
}
}
impl<W: Widget> IndexMut<StaticWidgetId<W>> for Ui {
fn index_mut(&mut self, id: StaticWidgetId<W>) -> &mut Self::Output {
self.updates.insert(id.id);
self.data.widgets.get_mut(&id).unwrap()
}
}
impl dyn Widget {
pub fn as_any(&self) -> &dyn Any {
self