Skip to content

Commit

Permalink
Potential fix for for-loop memory leak (#1010)
Browse files Browse the repository at this point in the history
* fix for-loop memory leak

* remove additional unsafe call
  • Loading branch information
0xk1f0 authored Feb 17, 2024
1 parent d497726 commit 9cbbcb9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/eww/src/widgets/build_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn build_loop_special_widget(
.collect_vec();
let mut created_children = created_children.borrow_mut();
for old_child in created_children.drain(..) {
unsafe { old_child.destroy() };
gtk_container.remove(&old_child);
}
let mut created_child_scopes = created_child_scopes.borrow_mut();
for child_scope in created_child_scopes.drain(..) {
Expand Down Expand Up @@ -313,11 +313,7 @@ fn build_children_special_widget(
nth_child_widget_use.clone(),
None,
)?;
for old_child in child_container.children() {
unsafe {
old_child.destroy();
}
}
child_container.children().iter().for_each(|f| child_container.remove(f));
child_container.set_child(Some(&new_child_widget));
new_child_widget.show();
Ok(())
Expand Down

0 comments on commit 9cbbcb9

Please sign in to comment.