core: Fix Collect impl for BitmapData (fix #2009)

This commit is contained in:
Mike Welsh 2020-12-17 18:39:04 -08:00
parent 72a24b9800
commit a58073cabd
1 changed files with 4 additions and 16 deletions

View File

@ -18,7 +18,8 @@ use gc_arena::{Collect, Gc, GcCell};
#[collect(no_drop)] #[collect(no_drop)]
pub struct Bitmap<'gc>(GcCell<'gc, BitmapData<'gc>>); pub struct Bitmap<'gc>(GcCell<'gc, BitmapData<'gc>>);
#[derive(Clone, Debug)] #[derive(Clone, Debug, Collect)]
#[collect(no_drop)]
pub struct BitmapData<'gc> { pub struct BitmapData<'gc> {
base: DisplayObjectBase<'gc>, base: DisplayObjectBase<'gc>,
static_data: Gc<'gc, BitmapStatic>, static_data: Gc<'gc, BitmapStatic>,
@ -131,25 +132,12 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> {
} }
} }
unsafe impl<'gc> gc_arena::Collect for BitmapData<'gc> {
fn trace(&self, cc: gc_arena::CollectionContext) {
self.base.trace(cc);
self.static_data.trace(cc);
}
}
/// Static data shared between all instances of a bitmap. /// Static data shared between all instances of a bitmap.
#[derive(Clone)] #[derive(Clone, Collect)]
#[collect(no_drop)]
struct BitmapStatic { struct BitmapStatic {
id: CharacterId, id: CharacterId,
bitmap_handle: BitmapHandle, bitmap_handle: BitmapHandle,
width: u16, width: u16,
height: u16, height: u16,
} }
unsafe impl<'gc> gc_arena::Collect for BitmapStatic {
#[inline]
fn needs_trace() -> bool {
true
}
}