Fix repeated subscription to dropped scope leak (#3569)

* Fix repeated subscription to dropped scope leak

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2025-01-16 17:35:14 -08:00
1 parent c7951b7dd5
commit e22ea0c2ff
1 file changed
+14
+14
View File
@@ -311,3 +311,17 @@ struct Inner {
// The scope that this reactive context is associated with
scope: Option<ScopeId>,
}
impl Drop for Inner {
fn drop(&mut self) {
let Some(self_) = self.self_.take() else {
return;
};
for subscriber in std::mem::take(&mut self.subscribers) {
if let Ok(mut subscriber) = subscriber.0.lock() {
subscriber.remove(&self_);
}
}
}
}