From b1a71174db51eb0c3283a2d734b98c68ae588193 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 10 Jul 2018 23:09:59 +0200 Subject: [PATCH] Messages are also safe. --- client/TracyProfiler.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 873f518a..f396378d 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -184,7 +184,9 @@ public: static tracy_force_inline void Message( const char* txt, size_t size ) { -#ifndef TRACY_ON_DEMAND +#ifdef TRACY_ON_DEMAND + if( !s_profiler.IsConnected() ) return; +#endif Magic magic; auto& token = s_token.ptr; auto ptr = (char*)tracy_malloc( size+1 ); @@ -197,12 +199,13 @@ public: MemWrite( &item->message.thread, GetThreadHandle() ); MemWrite( &item->message.text, (uint64_t)ptr ); tail.store( magic + 1, std::memory_order_release ); -#endif } static tracy_force_inline void Message( const char* txt ) { -#ifndef TRACY_ON_DEMAND +#ifdef TRACY_ON_DEMAND + if( !s_profiler.IsConnected() ) return; +#endif Magic magic; auto& token = s_token.ptr; auto& tail = token->get_tail_index(); @@ -212,7 +215,6 @@ public: MemWrite( &item->message.thread, GetThreadHandle() ); MemWrite( &item->message.text, (uint64_t)txt ); tail.store( magic + 1, std::memory_order_release ); -#endif } static tracy_force_inline void MemAlloc( const void* ptr, size_t size )