avm2: Don't create new texts/sprites/buttons with an empty movie

This commit is contained in:
Nathan Adams 2023-03-17 20:14:53 +01:00
parent e5f75ff126
commit 27f28fb547
3 changed files with 3 additions and 7 deletions

View File

@ -7,8 +7,6 @@ use crate::avm2::value::Value;
use crate::avm2::Error;
use crate::avm2::Multiname;
use crate::display_object::{MovieClip, SoundTransform, TDisplayObject};
use crate::tag_utils::SwfMovie;
use std::sync::Arc;
use swf::{Rectangle, Twips};
/// Implements `flash.display.Sprite`'s `init` method, which is called from the constructor
@ -35,7 +33,7 @@ pub fn init_empty_sprite<'gc>(
let class_object = this
.instance_of()
.ok_or("Attempted to construct Sprite on a bare object")?;
let movie = Arc::new(SwfMovie::empty(activation.context.swf.version()));
let movie = activation.context.swf.clone();
let new_do = MovieClip::new_with_avm2(movie, this, class_object, activation.context.gc_context);
this.init_display_object(&mut activation.context, new_do.into());

View File

@ -8,9 +8,7 @@ use crate::avm2::Error;
use crate::display_object::{AutoSizeMode, EditText, TDisplayObject, TextSelection};
use crate::html::TextFormat;
use crate::string::AvmString;
use crate::tag_utils::SwfMovie;
use crate::{avm2_stub_getter, avm2_stub_setter};
use std::sync::Arc;
use swf::Color;
/// Implements `flash.text.TextField`'s `init` method, which is called from the constructor.
@ -23,7 +21,7 @@ pub fn init<'gc>(
activation.super_init(this, &[])?;
if this.as_display_object().is_none() {
let movie = Arc::new(SwfMovie::empty(activation.context.swf.version()));
let movie = activation.context.swf.clone();
let new_do = EditText::new(&mut activation.context, movie, 0.0, 0.0, 100.0, 100.0);
this.init_display_object(&mut activation.context, new_do.into());

View File

@ -137,7 +137,7 @@ impl<'gc> Avm2Button<'gc> {
}
pub fn empty_button(context: &mut UpdateContext<'_, 'gc>) -> Self {
let movie = Arc::new(SwfMovie::empty(context.swf.version()));
let movie = context.swf.clone();
let button_record = swf::Button {
id: 0,
is_track_as_menu: false,