Fix invalid tracy events from C# profiling api when profiler gets connected mid-event

This commit is contained in:
Wojtek Figat
2023-12-06 00:24:30 +01:00
parent 2285116bae
commit 38a0718b70
3 changed files with 14 additions and 5 deletions

View File

@@ -12,15 +12,16 @@
namespace tracy
{
void ScopedZone::Begin(const SourceLocationData* srcloc)
bool ScopedZone::Begin(const SourceLocationData* srcloc)
{
#ifdef TRACY_ON_DEMAND
if (!GetProfiler().IsConnected()) return;
if (!GetProfiler().IsConnected()) return false;
#endif
TracyLfqPrepare( QueueType::ZoneBegin );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommit( zoneBeginThread );
return true;
}
void ScopedZone::End()

View File

@@ -39,7 +39,7 @@ struct TRACY_API SourceLocationData
class TRACY_API ScopedZone
{
public:
static void Begin( const SourceLocationData* srcloc );
static bool Begin( const SourceLocationData* srcloc );
static void End();
ScopedZone( const ScopedZone& ) = delete;