avm2: Swapping children should lock them from depth manipulation.

This commit is contained in:
David Wendt 2020-11-14 16:50:54 -05:00 committed by Mike Welsh
parent c8cd4a9192
commit 35bc43cce2
1 changed files with 9 additions and 0 deletions

View File

@ -470,6 +470,12 @@ pub fn swap_children_at<'gc>(
return Err(format!("RangeError: Index {} is out of bounds", index1).into()); return Err(format!("RangeError: Index {} is out of bounds", index1).into());
} }
let child0 = ctr.child_by_id(index0 as usize).unwrap();
let child1 = ctr.child_by_id(index1 as usize).unwrap();
child0.set_placed_by_script(activation.context.gc_context, true);
child1.set_placed_by_script(activation.context.gc_context, true);
ctr.swap_at_id(&mut activation.context, index0 as usize, index1 as usize); ctr.swap_at_id(&mut activation.context, index0 as usize, index1 as usize);
} }
} }
@ -509,6 +515,9 @@ pub fn swap_children<'gc>(
.position(|a| DisplayObject::ptr_eq(a, child1)) .position(|a| DisplayObject::ptr_eq(a, child1))
.ok_or("ArgumentError: Child is not a child of this display object")?; .ok_or("ArgumentError: Child is not a child of this display object")?;
child0.set_placed_by_script(activation.context.gc_context, true);
child1.set_placed_by_script(activation.context.gc_context, true);
ctr.swap_at_id(&mut activation.context, index0, index1); ctr.swap_at_id(&mut activation.context, index0, index1);
} }
} }