avm1: SetTarget of a removed clip is invalid

A `SetTarget` call should ignore any clip that has been removed.
This can happen in cases such as `tellTarget("_root")` seeking
to a frame where the clip no longer exists.

Fixes this issue:
https://github.com/ruffle-rs/ruffle/pull/4452#issuecomment-860747028
This commit is contained in:
Mike Welsh 2021-06-14 13:32:13 -07:00
parent ed1bfd74fe
commit 2f25887080
1 changed files with 3 additions and 1 deletions

View File

@ -2959,7 +2959,9 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
/// Changes the target clip. /// Changes the target clip.
pub fn set_target_clip(&mut self, value: Option<DisplayObject<'gc>>) { pub fn set_target_clip(&mut self, value: Option<DisplayObject<'gc>>) {
self.target_clip = value; // The target should revert to `None` if the clip is removed.
let is_clip_removed = value.map(|clip| clip.removed()).unwrap_or_default();
self.target_clip = if !is_clip_removed { value } else { None }
} }
/// Define a local property on the activation. /// Define a local property on the activation.