From ed14ab5091f3d5d06189c0a5a625f0dedd96352d Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 30 Apr 2022 11:55:47 +0800 Subject: [PATCH] Fix possible exit crash --- src/main.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 42343b125..32f2956a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2689,6 +2689,21 @@ static void cleanSuperTuxKart() irr_driver->updateConfigIfRelevant(); AchievementsManager::destroy(); Referee::cleanup(); + + if (SFXManager::get() && + !SFXManager::get()->waitForReadyToDeleted(2.0f)) + { + Log::info("Thread", "SFXManager not stopping, exiting anyway."); + } + SFXManager::destroy(); + + // Music manager can not be deleted before the SFX thread is stopped + // (since SFX commands can contain music information, which are + // deleted by the music manager). + delete music_manager; + + // Race manager needs to be deleted after sfx manager as it checks for + // the kart size structure from race manager RaceManager::destroy(); if(grand_prix_manager) delete grand_prix_manager; if(highscore_manager) delete highscore_manager; @@ -2746,18 +2761,6 @@ static void cleanSuperTuxKart() } } - if (SFXManager::get() && - !SFXManager::get()->waitForReadyToDeleted(2.0f)) - { - Log::info("Thread", "SFXManager not stopping, exiting anyway."); - } - SFXManager::destroy(); - - // Music manager can not be deleted before the SFX thread is stopped - // (since SFX commands can contain music information, which are - // deleted by the music manager). - delete music_manager; - // The add-ons manager might still be called from a currenty running request // in the request manager, so it can not be deleted earlier. #ifndef SERVER_ONLY