core: Collect GC debt at the end of each frame
This commit is contained in:
parent
0143d9716e
commit
59c9385cb7
|
@ -249,6 +249,7 @@ unsafe impl<'gc> gc_arena::Collect for Button<'gc> {
|
|||
child.trace(cc);
|
||||
}
|
||||
}
|
||||
self.static_data.trace(cc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,3 +8,19 @@ pub enum Character<'gc> {
|
|||
Text(Box<crate::text::Text<'gc>>),
|
||||
Sound(crate::backend::audio::SoundHandle),
|
||||
}
|
||||
|
||||
unsafe impl<'gc> gc_arena::Collect for Character<'gc> {
|
||||
#[inline]
|
||||
fn trace(&self, cc: gc_arena::CollectionContext) {
|
||||
match self {
|
||||
Character::Graphic(c) => c.trace(cc),
|
||||
Character::MovieClip(c) => c.trace(cc),
|
||||
Character::Bitmap(c) => c.trace(cc),
|
||||
Character::Button(c) => c.trace(cc),
|
||||
Character::Font(c) => c.trace(cc),
|
||||
Character::MorphShape(c) => c.trace(cc),
|
||||
Character::Text(c) => c.trace(cc),
|
||||
Character::Sound(c) => c.trace(cc),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,8 @@ impl<'gc> DisplayObject<'gc> for Graphic<'gc> {
|
|||
}
|
||||
|
||||
unsafe impl<'gc> gc_arena::Collect for Graphic<'gc> {
|
||||
#[inline]
|
||||
fn needs_trace() -> bool {
|
||||
false
|
||||
fn trace(&self, cc: gc_arena::CollectionContext) {
|
||||
self.static_data.trace(cc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -438,6 +438,7 @@ unsafe impl<'gc> gc_arena::Collect for MovieClip<'gc> {
|
|||
for child in self.children.values() {
|
||||
child.trace(cc);
|
||||
}
|
||||
self.static_data.trace(cc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -366,6 +366,9 @@ impl<Audio: AudioBackend, Renderer: RenderBackend> Player<Audio, Renderer> {
|
|||
|
||||
// Update mouse state (check for new hovered button, etc.)
|
||||
self.update_roll_over();
|
||||
|
||||
// GC
|
||||
self.gc_arena.collect_all();
|
||||
}
|
||||
|
||||
pub fn render(&mut self) {
|
||||
|
|
Loading…
Reference in New Issue