Skip to content

Commit a5a9183

Browse files
avm2: Don't try to set display object properties on AVM1Movies
1 parent 20e3a43 commit a5a9183

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

core/src/display_object/container.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -753,26 +753,31 @@ impl<'gc> ChildContainer<'gc> {
753753
if child.has_explicit_name() {
754754
if let Some(name) = child.name() {
755755
if let Some(parent_obj) = parent.object2() {
756-
let parent_obj = Avm2Value::from(parent_obj);
757-
758-
let mut activation = Avm2Activation::from_nothing(context);
759-
let multiname =
760-
Avm2Multiname::new(activation.avm2().find_public_namespace(), name);
761-
let current_val = parent_obj.get_property(&multiname, &mut activation);
762-
match current_val {
763-
Ok(Avm2Value::Null) | Ok(Avm2Value::Undefined) => {}
764-
Ok(_other) => {
765-
let res = parent_obj.set_property(
766-
&multiname,
767-
Avm2Value::Null,
768-
&mut activation,
769-
);
770-
if let Err(e) = res {
771-
tracing::error!("Failed to set child {} ({:?}) to null on parent obj {:?}: {:?}", name, child, parent_obj, e);
756+
if child.movie().is_action_script_3() {
757+
let parent_obj = Avm2Value::from(parent_obj);
758+
759+
let mut activation = Avm2Activation::from_nothing(context);
760+
let multiname = Avm2Multiname::new(
761+
activation.avm2().find_public_namespace(),
762+
name,
763+
);
764+
let current_val =
765+
parent_obj.get_property(&multiname, &mut activation);
766+
match current_val {
767+
Ok(Avm2Value::Null) | Ok(Avm2Value::Undefined) => {}
768+
Ok(_other) => {
769+
let res = parent_obj.set_property(
770+
&multiname,
771+
Avm2Value::Null,
772+
&mut activation,
773+
);
774+
if let Err(e) = res {
775+
tracing::error!("Failed to set child {} ({:?}) to null on parent obj {:?}: {:?}", name, child, parent_obj, e);
776+
}
777+
}
778+
Err(e) => {
779+
tracing::error!("Failed to get current value of child {} ({:?}) on parent obj {:?}: {:?}", name, child, parent_obj, e);
772780
}
773-
}
774-
Err(e) => {
775-
tracing::error!("Failed to get current value of child {} ({:?}) on parent obj {:?}: {:?}", name, child, parent_obj, e);
776781
}
777782
}
778783
}

0 commit comments

Comments
 (0)