From f87fb2b2d65e49eaefcf279fc6d833cb5b564800 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 18 Jun 2023 23:55:58 +0200 Subject: [PATCH] Fix shutdown crash on debug builds The destruction of these crashed due to dereferencing an invalid pointer. Not making them inline fixes the problem. This problem only occurred on debug builds, other build configurations were not affected. --- r5dev/core/logdef.cpp | 4 ++++ r5dev/core/logdef.h | 4 ++-- r5dev/datacache/mdlcache.cpp | 3 +++ r5dev/datacache/mdlcache.h | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/r5dev/core/logdef.cpp b/r5dev/core/logdef.cpp index f6f08e8b..f4dabafe 100644 --- a/r5dev/core/logdef.cpp +++ b/r5dev/core/logdef.cpp @@ -4,6 +4,9 @@ std::shared_ptr g_TermLogger; std::shared_ptr g_ImGuiLogger; +std::ostringstream g_LogStream; +std::shared_ptr g_LogSink; + //############################################################################# // SPDLOG INIT //############################################################################# @@ -24,6 +27,7 @@ void SpdLog_Init(void) * IMGUI LOGGER SETUP * ************************/ { + g_LogSink = std::make_shared(g_LogStream); g_ImGuiLogger = std::make_shared("game_console", g_LogSink); spdlog::register_logger(g_ImGuiLogger); // in-game console logger. g_ImGuiLogger->set_pattern("[0.000] %v"); diff --git a/r5dev/core/logdef.h b/r5dev/core/logdef.h index e77ac593..2f998635 100644 --- a/r5dev/core/logdef.h +++ b/r5dev/core/logdef.h @@ -21,8 +21,8 @@ extern std::shared_ptr g_ImGuiLogger; //------------------------------------------------------------------------- // IMGUI CONSOLE SINK | -inline std::ostringstream g_LogStream; -inline auto g_LogSink = std::make_shared(g_LogStream); +extern std::ostringstream g_LogStream; +extern std::shared_ptr g_LogSink; void SpdLog_Init(void); void SpdLog_Create(void); diff --git a/r5dev/datacache/mdlcache.cpp b/r5dev/datacache/mdlcache.cpp index 3bc5622b..419da828 100644 --- a/r5dev/datacache/mdlcache.cpp +++ b/r5dev/datacache/mdlcache.cpp @@ -15,6 +15,9 @@ #include "rtech/rtech_utils.h" #include "public/studio.h" +RMDLFallBack_t* g_pMDLFallback = new RMDLFallBack_t(); +std::unordered_set g_vBadMDLHandles; + //----------------------------------------------------------------------------- // Purpose: finds an MDL diff --git a/r5dev/datacache/mdlcache.h b/r5dev/datacache/mdlcache.h index 092f8723..db44ec6c 100644 --- a/r5dev/datacache/mdlcache.h +++ b/r5dev/datacache/mdlcache.h @@ -60,8 +60,8 @@ struct studiodata_t int m_nGuidLock; // always -1, set to 1 and 0 in CMDLCache::FindUncachedMDL. }; -inline RMDLFallBack_t* g_pMDLFallback = new RMDLFallBack_t(); -inline std::unordered_set g_vBadMDLHandles; +extern RMDLFallBack_t* g_pMDLFallback; +extern std::unordered_set g_vBadMDLHandles; class CMDLCache {