mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 14:32:00 +00:00
fix: fix leaks in memos, and in scope parent tracking (#841)
This commit is contained in:
parent
4e1f963750
commit
70f3edb0f5
2 changed files with 8 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
|||
#![forbid(unsafe_code)]
|
||||
use crate::{
|
||||
create_effect, diagnostics::AccessDiagnostics, node::NodeId, on_cleanup,
|
||||
with_runtime, AnyComputation, RuntimeId, Scope, SignalDispose, SignalGet,
|
||||
SignalGetUntracked, SignalStream, SignalWith, SignalWithUntracked,
|
||||
with_runtime, AnyComputation, RuntimeId, Scope, ScopeProperty,
|
||||
SignalDispose, SignalGet, SignalGetUntracked, SignalStream, SignalWith,
|
||||
SignalWithUntracked,
|
||||
};
|
||||
use cfg_if::cfg_if;
|
||||
use std::{any::Any, cell::RefCell, fmt::Debug, marker::PhantomData, rc::Rc};
|
||||
|
@ -80,7 +81,9 @@ pub fn create_memo<T>(
|
|||
where
|
||||
T: PartialEq + 'static,
|
||||
{
|
||||
cx.runtime.create_memo(f)
|
||||
let memo = cx.runtime.create_memo(f);
|
||||
cx.push_scope_property(ScopeProperty::Effect(memo.id));
|
||||
memo
|
||||
}
|
||||
|
||||
/// An efficient derived reactive value based on other reactive values.
|
||||
|
|
|
@ -254,6 +254,8 @@ impl Scope {
|
|||
}
|
||||
}
|
||||
|
||||
runtime.scope_parents.borrow_mut().remove(self.id);
|
||||
|
||||
// remove everything we own and run cleanups
|
||||
let owned = {
|
||||
let owned = runtime.scopes.borrow_mut().remove(self.id);
|
||||
|
|
Loading…
Reference in a new issue