From afa432a08771f3b33a8ce8c5f3ef0217e94b11fc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 28 Apr 2018 15:49:51 +0200 Subject: [PATCH] Non-user plots must have predefined names. --- server/TracyView.cpp | 18 ++++++++++++++++-- server/TracyView.hpp | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 871bb8af..0110e7a2 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2392,7 +2392,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl { draw->AddTriangle( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( to/2, offset + ty - to/2 ), wpos + ImVec2( to/2 + th, offset + ty * 0.5 ), 0xFF226E6E ); } - const auto txt = m_worker.GetString( v->name ); + const auto txt = GetPlotName( v ); draw->AddText( wpos + ImVec2( ty, offset ), showFull ? 0xFF44DDDD : 0xFF226E6E, txt ); draw->AddLine( wpos + ImVec2( 0, offset + ty - 1 ), wpos + ImVec2( w, offset + ty - 1 ), 0x8844DDDD ); @@ -3014,7 +3014,7 @@ void View::DrawOptions() { for( const auto& p : m_worker.GetPlots() ) { - ImGui::Checkbox( m_worker.GetString( p->name ), &Visible( p ) ); + ImGui::Checkbox( GetPlotName( p ), &Visible( p ) ); } ImGui::TreePop(); } @@ -4907,6 +4907,20 @@ Vector View::GetMemoryPages() const return ret; } +const char* View::GetPlotName( const PlotData* plot ) const +{ + switch( plot->type ) + { + case PlotType::User: + return m_worker.GetString( plot->name ); + case PlotType::Memory: + return "Memory usage"; + default: + assert( false ); + return nullptr; + } +} + uint32_t View::GetZoneColor( const ZoneEvent& ev ) { const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6a5ac571..e363b84a 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -116,6 +116,7 @@ private: #endif Vector GetMemoryPages() const; + const char* GetPlotName( const PlotData* plot ) const; flat_hash_map> m_visible; flat_hash_map> m_showFull;