fix on_id widget refcount leak (-> memory leak)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
core::WidgetPtr,
|
||||
layout::{Len, Painter, SizeCtx, StaticWidgetId, Ui, WidgetId, WidgetIdFn},
|
||||
layout::{Len, Painter, SizeCtx, Ui, WidgetId, WidgetIdFn},
|
||||
};
|
||||
|
||||
use std::{any::Any, marker::PhantomData};
|
||||
@@ -26,7 +26,9 @@ pub struct FnTag;
|
||||
|
||||
pub trait WidgetLike<Tag> {
|
||||
type Widget: 'static;
|
||||
|
||||
fn add(self, ui: &mut Ui) -> WidgetId<Self::Widget>;
|
||||
|
||||
fn with_id<W2>(
|
||||
self,
|
||||
f: impl FnOnce(&mut Ui, WidgetId<Self::Widget>) -> WidgetId<W2>,
|
||||
@@ -39,18 +41,14 @@ pub trait WidgetLike<Tag> {
|
||||
f(ui, id)
|
||||
}
|
||||
}
|
||||
fn add_static(self, ui: &mut Ui) -> StaticWidgetId<Self::Widget>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.add(ui).into_static()
|
||||
}
|
||||
|
||||
fn set_root(self, ui: &mut Ui)
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
ui.set_root(self);
|
||||
}
|
||||
|
||||
fn set_ptr(self, ptr: &WidgetId<WidgetPtr>, ui: &mut Ui)
|
||||
where
|
||||
Self: Sized,
|
||||
|
||||
Reference in New Issue
Block a user