1
0
Эх сурвалжийг харах

Fix repeated subscription to dropped scope leak (#3569)

* Fix repeated subscription to dropped scope leak

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Evan Almloff 5 сар өмнө
parent
commit
e22ea0c2ff

+ 14 - 0
packages/core/src/reactive_context.rs

@@ -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_);
+            }
+        }
+    }
+}