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:
1 parent
c7951b7dd5
commit
e22ea0c2ff
1 file changed
+14
@@ -311,3 +311,17 @@ struct Inner {
|
|||||||
// The scope that this reactive context is associated with
|
// The scope that this reactive context is associated with
|
||||||
scope: Option<ScopeId>,
|
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_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user