mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-11 07:04:13 +00:00
fix: try to guard against double drop
This commit is contained in:
parent
651ab3e7e3
commit
56d193d196
1 changed files with 5 additions and 4 deletions
|
@ -136,8 +136,8 @@ impl VirtualDom {
|
|||
}
|
||||
|
||||
/// Descend through the tree, removing any borrowed props and listeners
|
||||
pub(crate) fn ensure_drop_safety(&self, scope: ScopeId) {
|
||||
let scope = &self.scopes[scope.0];
|
||||
pub(crate) fn ensure_drop_safety(&self, scope_id: ScopeId) {
|
||||
let scope = &self.scopes[scope_id.0];
|
||||
|
||||
// make sure we drop all borrowed props manually to guarantee that their drop implementation is called before we
|
||||
// run the hooks (which hold an &mut Reference)
|
||||
|
@ -145,8 +145,9 @@ impl VirtualDom {
|
|||
let mut props = scope.borrowed_props.borrow_mut();
|
||||
props.drain(..).for_each(|comp| {
|
||||
let comp = unsafe { &*comp };
|
||||
if let Some(scope_id) = comp.scope.get() {
|
||||
self.ensure_drop_safety(scope_id);
|
||||
match comp.scope.get() {
|
||||
Some(child) if child != scope_id => self.ensure_drop_safety(child),
|
||||
_ => (),
|
||||
}
|
||||
drop(comp.props.take());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue