Fix memory leak in ListState

This commit is contained in:
Antonio Scandurra 2022-05-30 18:29:51 +02:00
parent 20e1044d49
commit f832c0074f

View file

@ -352,10 +352,11 @@ impl ListState {
{
let mut items = SumTree::new();
items.extend((0..element_count).map(|_| ListItem::Unrendered), &());
let handle = cx.handle();
let handle = cx.weak_handle();
Self(Rc::new(RefCell::new(StateInner {
last_layout_width: None,
render_item: Box::new(move |ix, cx| {
let handle = handle.upgrade(cx)?;
Some(cx.render(&handle, |view, cx| render_item(view, ix, cx)))
}),
rendered_range: 0..0,