Fix Widget::tag implementation of pure::Canvas

Using `P::State` can cause a panic if the `Canvas` has `()` as
`P::State` and replaces a stateless widget in a future `view` call.
This commit is contained in:
Héctor Ramón Jiménez 2022-07-01 03:37:28 +02:00
parent 799a7e501d
commit 9330a83775
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 3 additions and 3 deletions

View file

@ -70,8 +70,6 @@ where
})
}
struct Tag<T>(T);
struct Instance<'a, Message, Renderer, Event, S> {
state: RefCell<Option<State<'a, Message, Renderer, Event, S>>>,
}
@ -132,6 +130,7 @@ where
Renderer: iced_native::Renderer,
{
fn tag(&self) -> tree::Tag {
struct Tag<T>(T);
tree::Tag::of::<Tag<S>>()
}