Skip to content

Commit

Permalink
Fix recycling on component callbacks (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelleyrtp authored Apr 4, 2024
1 parent 0a32910 commit 702509c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Drop for VNode {
for attrs in self.vnode.dynamic_attrs.iter() {
for attr in attrs.iter() {
if let AttributeValue::Listener(listener) = &attr.value {
listener.callback.manually_drop();
listener.callback.recycle();
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions packages/generational-box/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,17 @@ impl<T, S: Storage<T>> GenerationalBox<T, S> {
}
}

/// Drop the value out of the generational box and invalidate the generational box. This will return the value if the value was taken.
/// Recycle the generationalbox, dropping the value.
pub fn recycle(&self) {
_ = Storage::take(&self.raw.0.data);
<S as AnyStorage>::recycle(&self.raw);
}

/// Drop the value out of the generational box and invalidate the generational box.
/// This will return the value if the value was taken.
pub fn manually_drop(&self) -> Option<T> {
if self.validate() {
let o = Storage::take(&self.raw.0.data);
<S as AnyStorage>::recycle(&self.raw);
o
Storage::take(&self.raw.0.data)
} else {
None
}
Expand Down

0 comments on commit 702509c

Please sign in to comment.