From 5936e7c86cfd978c210922b46598a5cf0c4dcddf Mon Sep 17 00:00:00 2001 From: JIA-ss <62920066+JIA-ss@users.noreply.github.com> Date: Sun, 25 Jul 2021 17:28:42 +0800 Subject: [PATCH] Multi Dll Proj will Crash, Under Unity (#244) --- client/TracyProfiler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 2c58b370..ac76baef 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -960,15 +960,17 @@ thread_local bool RpThreadInitDone = false; # ifdef TRACY_MANUAL_LIFETIME ProfilerData* s_profilerData = nullptr; +static ProfilerThreadData& GetProfilerThreadData(); TRACY_API void StartupProfiler() { s_profilerData = (ProfilerData*)tracy_malloc( sizeof( ProfilerData ) ); new (s_profilerData) ProfilerData(); s_profilerData->profiler.SpawnWorkerThreads(); + GetProfilerThreadData().token = ProducerWrapper( *s_profilerData ); } static ProfilerData& GetProfilerData() { - assert(s_profilerData); + assert( s_profilerData ); return *s_profilerData; } TRACY_API void ShutdownProfiler() @@ -977,6 +979,8 @@ TRACY_API void ShutdownProfiler() tracy_free( s_profilerData ); s_profilerData = nullptr; rpmalloc_finalize(); + RpThreadInitDone = false; + RpInitDone.store( 0, std::memory_order_release ); } # else static std::atomic profilerDataLock { 0 };