diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 10b1a3e9..cad711cd 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -845,7 +845,7 @@ bool View::DrawImpl() { ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); } - ImGui::Text( "%s: %s", m_frames->name == 0 ? "Frames" : m_worker.GetString( m_frames->name ), RealToString( m_worker.GetFrameCount( *m_frames ) ) ); + ImGui::Text( "%s: %s", GetFrameSetName( *m_frames ), RealToString( m_worker.GetFrameCount( *m_frames ) ) ); if( !vis ) { ImGui::PopStyleColor(); @@ -861,7 +861,7 @@ bool View::DrawImpl() for( auto& fd : frames ) { bool isSelected = m_frames == fd; - if( ImGui::Selectable( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), isSelected ) ) + if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) ) { m_frames = fd; } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 689c1e92..08222bd5 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -303,6 +303,8 @@ private: const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const; uint64_t GetFrameNumber( const FrameData& fd, int i, uint64_t offset ) const; const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const; + const char* GetFrameSetName( const FrameData& fd ) const; + static const char* GetFrameSetName( const FrameData& fd, const Worker& worker ); #ifndef TRACY_NO_STATISTICS void FindZones(); diff --git a/server/TracyView_Compare.cpp b/server/TracyView_Compare.cpp index 7c61a63c..44c60774 100644 --- a/server/TracyView_Compare.cpp +++ b/server/TracyView_Compare.cpp @@ -405,7 +405,7 @@ void View::DrawCompare() int idx = 0; for( auto& v : f0 ) { - const auto name = m_worker.GetString( v->name ); + const auto name = GetFrameSetName( *v ); ImGui::PushID( -1 - idx ); ImGui::RadioButton( name, &m_compare.selMatch[0], idx++ ); ImGui::SameLine(); @@ -418,7 +418,7 @@ void View::DrawCompare() idx = 0; for( auto& v : f1 ) { - const auto name = m_compare.second->GetString( v->name ); + const auto name = GetFrameSetName( *v, *m_compare.second ); ImGui::PushID( idx ); ImGui::RadioButton( name, &m_compare.selMatch[1], idx++ ); ImGui::SameLine(); @@ -435,8 +435,8 @@ void View::DrawCompare() if( m_compare.link ) { - auto string0 = m_worker.GetString( f0[m_compare.selMatch[0]]->name ); - auto string1 = m_compare.second->GetString( f1[m_compare.selMatch[1]]->name ); + auto string0 = GetFrameSetName( *f0[m_compare.selMatch[0]] ); + auto string1 = GetFrameSetName( *f1[m_compare.selMatch[1]], *m_compare.second ); if( strcmp( string0, string1 ) != 0 ) { @@ -445,7 +445,7 @@ void View::DrawCompare() { for( auto& v : f1 ) { - auto string = m_compare.second->GetString( v->name ); + auto string = GetFrameSetName( *v, *m_compare.second ); if( strcmp( string0, string ) == 0 ) { m_compare.selMatch[1] = idx; @@ -459,7 +459,7 @@ void View::DrawCompare() assert( prev1 != m_compare.selMatch[1] ); for( auto& v : f0 ) { - auto string = m_worker.GetString( v->name ); + auto string = GetFrameSetName( *v ); if( strcmp( string1, string ) == 0 ) { m_compare.selMatch[0] = idx; diff --git a/server/TracyView_FrameOverview.cpp b/server/TracyView_FrameOverview.cpp index cab989df..6daa9961 100644 --- a/server/TracyView_FrameOverview.cpp +++ b/server/TracyView_FrameOverview.cpp @@ -185,7 +185,7 @@ void View::DrawFrames() } else { - ImGui::TextDisabled( "%s:", m_worker.GetString( m_frames->name ) ); + ImGui::TextDisabled( "%s:", GetFrameSetName( *m_frames ) ); ImGui::SameLine(); ImGui::TextUnformatted( RealToString( fnum ) ); ImGui::Separator(); diff --git a/server/TracyView_FrameTimeline.cpp b/server/TracyView_FrameTimeline.cpp index f99a7c0a..96ab66b1 100644 --- a/server/TracyView_FrameTimeline.cpp +++ b/server/TracyView_FrameTimeline.cpp @@ -320,7 +320,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) ImGui::BeginTooltip(); TextDisabledUnformatted( "Frame set:" ); ImGui::SameLine(); - ImGui::TextUnformatted( frames.name == 0 ? "Frames" : m_worker.GetString( frames.name ) ); + ImGui::TextUnformatted( GetFrameSetName( frames ) ); ImGui::EndTooltip(); } if( IsMouseClicked( 0 ) ) diff --git a/server/TracyView_Options.cpp b/server/TracyView_Options.cpp index c3a7d34a..bbe13c5c 100644 --- a/server/TracyView_Options.cpp +++ b/server/TracyView_Options.cpp @@ -701,7 +701,7 @@ void View::DrawOptions() for( const auto& fd : m_worker.GetFrames() ) { ImGui::PushID( idx++ ); - SmallCheckbox( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), &Vis( fd ).visible ); + SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ).visible ); ImGui::PopID(); ImGui::SameLine(); ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " ); diff --git a/server/TracyView_TraceInfo.cpp b/server/TracyView_TraceInfo.cpp index 373b8e08..e17cd8a3 100644 --- a/server/TracyView_TraceInfo.cpp +++ b/server/TracyView_TraceInfo.cpp @@ -188,7 +188,7 @@ void View::DrawInfo() auto fsz = m_worker.GetFullFrameCount( *m_frames ); if( fsz != 0 ) { - TextFocused( "Frame set:", m_frames->name == 0 ? "Frames" : m_worker.GetString( m_frames->name ) ); + TextFocused( "Frame set:", GetFrameSetName( *m_frames ) ); ImGui::SameLine(); ImGui::TextDisabled( "(%s)", m_frames->continuous ? "continuous" : "discontinuous" ); ImGui::SameLine(); @@ -199,7 +199,7 @@ void View::DrawInfo() for( auto& fd : frames ) { bool isSelected = m_frames == fd; - if( ImGui::Selectable( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), isSelected ) ) + if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) ) { m_frames = fd; fsz = m_worker.GetFullFrameCount( *m_frames ); diff --git a/server/TracyView_Utility.cpp b/server/TracyView_Utility.cpp index ff094120..ca603b3e 100644 --- a/server/TracyView_Utility.cpp +++ b/server/TracyView_Utility.cpp @@ -1,3 +1,5 @@ +#include + #include "TracyColor.hpp" #include "TracyPrint.hpp" #include "TracyView.hpp" @@ -791,11 +793,32 @@ const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint } else { - sprintf( buf, "%s %s (%s)", m_worker.GetString( fd.name ), RealToString( fnum ), TimeToString( ftime ) ); + sprintf( buf, "%s %s (%s)", GetFrameSetName( fd ), RealToString( fnum ), TimeToString( ftime ) ); } return buf; } +const char* View::GetFrameSetName( const FrameData& fd ) const +{ + return GetFrameSetName( fd, m_worker ); +} + +const char* View::GetFrameSetName( const FrameData& fd, const Worker& worker ) +{ + enum { Pool = 4 }; + static char bufpool[Pool][64]; + static int bufsel = 0; + + if( fd.name == 0 ) + { + return "Frames"; + } + else + { + return worker.GetString( fd.name ); + } +} + const char* View::ShortenNamespace( const char* name ) const { if( m_namespace == Namespace::Full ) return name;