Skip to content

Commit 1c209a2

Browse files
committed
core: Put Character::BinaryData's field behind a Gc
1 parent 8642905 commit 1c209a2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

core/src/avm2/object/bytearray_object.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::avm2::value::Value;
66
use crate::avm2::Error;
77
use crate::avm2::Multiname;
88
use crate::character::Character;
9+
use crate::tag_utils::SwfSlice;
910
use crate::utils::HasPrefixField;
1011
use core::fmt;
1112
use gc_arena::{Collect, Gc, GcWeak};
@@ -24,7 +25,9 @@ pub fn byte_array_allocator<'gc>(
2425
{
2526
if let Some(lib) = activation.context.library.library_for_movie(movie) {
2627
if let Some(Character::BinaryData(binary_data)) = lib.character_by_id(id) {
27-
Some(ByteArrayStorage::from_vec(binary_data.as_ref().to_vec()))
28+
Some(ByteArrayStorage::from_vec(
29+
SwfSlice::as_ref(binary_data).to_vec(),
30+
))
2831
} else {
2932
None
3033
}

core/src/character.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::display_object::{
66
Avm1Button, Avm2Button, BitmapClass, EditText, Graphic, MorphShape, MovieClip, Text, Video,
77
};
88
use crate::font::Font;
9-
use gc_arena::{Collect, GcCell};
9+
use gc_arena::{Collect, Gc, GcCell};
1010
use ruffle_render::bitmap::{BitmapHandle, BitmapSize};
1111
use swf::DefineBitsLossless;
1212

@@ -33,7 +33,7 @@ pub enum Character<'gc> {
3333
Text(Text<'gc>),
3434
Sound(#[collect(require_static)] SoundHandle),
3535
Video(Video<'gc>),
36-
BinaryData(BinaryData),
36+
BinaryData(Gc<'gc, BinaryData>),
3737
}
3838

3939
/// Holds a bitmap from an SWF tag, plus the decoded width/height.

core/src/display_object/movie_clip.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,7 @@ impl<'gc, 'a> MovieClipShared<'gc> {
36783678
) -> Result<(), Error> {
36793679
let tag_data = reader.read_define_binary_data()?;
36803680
let binary_data = BinaryData::from_swf_tag(self.movie(), &tag_data);
3681+
let binary_data = Gc::new(context.gc(), binary_data);
36813682
self.library_mut(context)
36823683
.register_character(tag_data.id, Character::BinaryData(binary_data));
36833684
Ok(())

0 commit comments

Comments
 (0)