core: Fix ChildContainer.replace_at_depth() panic
Avoid panic in ChildContainer.replace_at_depth() panic when previous child is not in render list. --------- Co-authored-by: Gleb Piskunov <emgfc@ya.ru>
This commit is contained in:
parent
3b7172de8d
commit
6f7e491bc5
|
@ -637,12 +637,11 @@ impl<'gc> ChildContainer<'gc> {
|
|||
) -> Option<DisplayObject<'gc>> {
|
||||
let prev_child = self.insert_child_into_depth_list(depth, child);
|
||||
if let Some(prev_child) = prev_child {
|
||||
let position = self
|
||||
if let Some(position) = self
|
||||
.render_list
|
||||
.iter()
|
||||
.position(|x| DisplayObject::ptr_eq(*x, prev_child))
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
if !prev_child.placed_by_script() {
|
||||
self.replace_id(position, child);
|
||||
Some(prev_child)
|
||||
|
@ -650,6 +649,13 @@ impl<'gc> ChildContainer<'gc> {
|
|||
self.insert_id(position + 1, child);
|
||||
None
|
||||
}
|
||||
} else {
|
||||
tracing::error!(
|
||||
"ChildContainer::replace_at_depth: Previous child is not in render list"
|
||||
);
|
||||
self.push_id(child);
|
||||
None
|
||||
}
|
||||
} else {
|
||||
let above = self
|
||||
.depth_list
|
||||
|
|
Loading…
Reference in New Issue