diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 317c17a1a..4173f9145 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -974,21 +974,39 @@ namespace GUIEngine if (ScreenKeyboard::isActive()) ScreenKeyboard::dismiss(); if (ModalDialog::isADialogActive()) ModalDialog::dismiss(); - //delete g_font; - g_font->drop(); - g_font = NULL; - //delete g_title_font; - g_title_font->drop(); - g_title_font = NULL; - //delete g_small_font; - g_small_font->drop(); - g_small_font = NULL; - g_large_font->drop(); - g_large_font = NULL; - g_digit_font->drop(); - g_digit_font = NULL; - g_outline_font->drop(); - g_outline_font = NULL; + if (g_font) + { + //delete g_font; + g_font->drop(); + g_font = NULL; + } + if (g_title_font) + { + //delete g_title_font; + g_title_font->drop(); + g_title_font = NULL; + } + if (g_small_font) + { + //delete g_small_font; + g_small_font->drop(); + g_small_font = NULL; + } + if (g_large_font) + { + g_large_font->drop(); + g_large_font = NULL; + } + if (g_digit_font) + { + g_digit_font->drop(); + g_digit_font = NULL; + } + if (g_outline_font) + { + g_outline_font->drop(); + g_outline_font = NULL; + } // nothing else to delete for now AFAIK, irrlicht will automatically // kill everything along the device diff --git a/src/main.cpp b/src/main.cpp index e9886ac0e..a02b7e3fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2338,6 +2338,9 @@ static void cleanSuperTuxKart() if(unlock_manager) delete unlock_manager; Online::ProfileManager::destroy(); GUIEngine::DialogQueue::deallocate(); + GUIEngine::clear(); + GUIEngine::cleanUp(); + GUIEngine::clearScreenCache(); if(font_manager) delete font_manager; // Now finish shutting down objects which a separate thread. The