fix: proprogation of root context
This commit is contained in:
1 parent
70f2ef43db
commit
c8d528b3b1
1 file changed
+11
-8
@@ -702,19 +702,22 @@ impl ScopeState {
|
|||||||
while let Some(parent) = search_parent.take() {
|
while let Some(parent) = search_parent.take() {
|
||||||
let parent = unsafe { &*parent };
|
let parent = unsafe { &*parent };
|
||||||
|
|
||||||
if parent
|
if parent.scope_id() == ScopeId(0) {
|
||||||
.shared_contexts
|
let exists = parent
|
||||||
.borrow_mut()
|
.shared_contexts
|
||||||
.insert(TypeId::of::<T>(), value.clone())
|
.borrow_mut()
|
||||||
.is_some()
|
.insert(TypeId::of::<T>(), value.clone());
|
||||||
{
|
|
||||||
log::warn!("Context already provided to parent scope - replacing it");
|
if exists.is_some() {
|
||||||
|
log::warn!("Context already provided to parent scope - replacing it");
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
search_parent = parent.parent_scope;
|
search_parent = parent.parent_scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
value
|
unreachable!("all apps have a root scope")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to retrieve a SharedState with type T from the any parent Scope.
|
/// Try to retrieve a SharedState with type T from the any parent Scope.
|
||||||
|
|||||||
Reference in new issue
Block a user