From d56e4d58886a04169b9ddd639536260fbd23d93d Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 7 Apr 2022 23:07:58 +0100 Subject: [PATCH] Correctly remove dynamic tiles if not committing a text renderer --- agb/src/display/font.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index 70b8a136..badafc56 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -161,3 +161,13 @@ impl<'a> TextRenderer<'a> { } } } + +impl<'a> Drop for TextRenderer<'a> { + fn drop(&mut self) { + let tiles = core::mem::take(&mut self.tiles); + + for (_, tile) in tiles.into_iter() { + self.vram_manager.remove_dynamic_tile(tile); + } + } +}