From fc01be2138a0f13fccc1147fe735466158cc0004 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 20 Sep 2017 20:38:12 +0200 Subject: [PATCH] Don't show profiler window before connection is established. --- server/TracyView.cpp | 12 +++++++++++- server/TracyView.hpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 6ad638f2..266055d7 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -24,6 +24,7 @@ View::View( const char* addr ) : m_addr( addr ) , m_shutdown( false ) , m_connected( false ) + , m_hasData( false ) , m_mbps( 64 ) , m_stream( LZ4_createStreamDecode() ) , m_buffer( new char[TargetFrameSize*3] ) @@ -80,8 +81,9 @@ void View::Worker() if( !m_sock.Read( &lz4, sizeof( lz4 ), &tv, ShouldExit ) ) goto close; m_frames.push_back( timeStart ); - LZ4_setStreamDecode( m_stream, nullptr, 0 ); + m_hasData.store( true, std::memory_order_release ); + LZ4_setStreamDecode( m_stream, nullptr, 0 ); m_connected.store( true, std::memory_order_relaxed ); t0 = std::chrono::high_resolution_clock::now(); @@ -366,6 +368,14 @@ void View::Draw() void View::DrawImpl() { + if( !m_hasData.load( std::memory_order_acquire ) ) + { + ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders ); + ImGui::Text( "Waiting for connection..." ); + ImGui::End(); + return; + } + // Connection window ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders ); { diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6fa4b084..bb4c205e 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -61,6 +61,7 @@ private: std::thread m_thread; std::atomic m_shutdown; std::atomic m_connected; + std::atomic m_hasData; // this block must be locked std::mutex m_lock;