diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 1a7c6cffaa..113dc8200a 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -156,6 +156,9 @@ LogManager::~LogManager() { #endif } + // Make sure we don't shutdown while logging. RemoveListener locks too, but there are gaps. + std::lock_guard listeners_lock(listeners_lock_); + if (fileLog_) delete fileLog_; #if !defined(MOBILE_DEVICE) || defined(_DEBUG) @@ -262,6 +265,7 @@ bool LogManager::IsEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type) } void LogManager::Init(bool *enabledSetting) { + _assert_(logManager_ == nullptr); logManager_ = new LogManager(enabledSetting); } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d51adad672..7fdf56e5e9 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1402,14 +1402,6 @@ void NativeShutdown() { #endif g_Config.Save("NativeShutdown"); - // Avoid shutting this down when restarting core. - if (!restarting) - LogManager::Shutdown(); - -#ifdef ANDROID_NDK_PROFILER - moncleanup(); -#endif - INFO_LOG(SYSTEM, "NativeShutdown called"); ShutdownWebServer(); @@ -1420,6 +1412,14 @@ void NativeShutdown() { g_Discord.Shutdown(); + // Avoid shutting this down when restarting core. + if (!restarting) + LogManager::Shutdown(); + +#ifdef ANDROID_NDK_PROFILER + moncleanup(); +#endif + if (logger) { delete logger; logger = nullptr;