From 2aab911196811540ccc47acb8a99411898bd308e Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 26 Oct 2010 15:23:04 -0700 Subject: [PATCH] Add destroy_default_font() to avoid memory leak of the default font. --- src/modules/gui.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index 1af9f6283..381cc934b 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -147,6 +147,7 @@ static JList icon_buttons; static bool double_buffering; static int screen_scaling; +static void destroy_default_font(); static void reload_default_font(); /* load & save graphics configuration */ @@ -357,6 +358,11 @@ void exit_module_gui() icon_buttons = NULL; jmanager_free(manager); + + // Destroy the default font of the current theme + destroy_default_font(); + + // Now we can destroy theme ji_set_theme(NULL); delete ase_theme; @@ -593,17 +599,24 @@ void gui_setup_screen(bool reload_font) save_gui_config(); } -static void reload_default_font() +static void destroy_default_font() { JTheme theme = ji_get_theme(); - SkinneableTheme* skinneable_theme = static_cast(theme); - const char *user_font; // No font for now if (theme->default_font && theme->default_font != font) destroy_font(theme->default_font); theme->default_font = NULL; +} + +static void reload_default_font() +{ + JTheme theme = ji_get_theme(); + SkinneableTheme* skinneable_theme = static_cast(theme); + const char *user_font; + + destroy_default_font(); // Directories ResourceFinder rf;