mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 16:54:41 -05:00
Compare commits
2 Commits
document-a
...
3086
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb05e080e5 | ||
|
|
9f7bacfcf9 |
@@ -171,12 +171,26 @@ impl KeyMap {
|
||||
where
|
||||
K: Debug + Hash + PartialEq + Eq + Send + Sync + 'static,
|
||||
{
|
||||
// this incredibly defensive mechanism takes the guard twice
|
||||
// on initialization. unfortunately, this is because `initialize`, on
|
||||
// a nested keyed field can, when being initialized), can in fact try
|
||||
// to take the lock again, as we try to insert the keys of the parent
|
||||
// while inserting the keys on this child.
|
||||
//
|
||||
// see here https://github.com/leptos-rs/leptos/issues/3086
|
||||
let mut guard = self.0.write().or_poisoned();
|
||||
let entry = guard
|
||||
.entry(path)
|
||||
.or_insert_with(|| Box::new(FieldKeys::new(initialize())));
|
||||
let entry = entry.downcast_mut::<FieldKeys<K>>()?;
|
||||
Some(fun(entry))
|
||||
if guard.contains_key(&path) {
|
||||
let entry = guard.get_mut(&path)?;
|
||||
let entry = entry.downcast_mut::<FieldKeys<K>>()?;
|
||||
Some(fun(entry))
|
||||
} else {
|
||||
drop(guard);
|
||||
let keys = Box::new(FieldKeys::new(initialize()));
|
||||
let mut guard = self.0.write().or_poisoned();
|
||||
let entry = guard.entry(path).or_insert(keys);
|
||||
let entry = entry.downcast_mut::<FieldKeys<K>>()?;
|
||||
Some(fun(entry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user