From 10f51e1eeee03d6a1258aa4b6570c63ae9e0756e Mon Sep 17 00:00:00 2001 From: Evan Klitzke Date: Thu, 19 Nov 2020 16:30:02 -0800 Subject: [PATCH] sort threads by tid --- server/TracyView.cpp | 8 ++++++++ server/TracyView.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index bce1a8ed..b5e08320 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3058,6 +3058,7 @@ void View::DrawZones() { m_threadOrder.push_back( threadData[i] ); } + SortThreads(); } auto& crash = m_worker.GetCrashEvent(); @@ -8991,6 +8992,7 @@ void View::DrawOptions() m_threadOrder.insert( m_threadOrder.begin() + target, srcval ); m_threadOrder.erase( m_threadOrder.begin() + source ); } + SortThreads(); } } ImGui::TreePop(); @@ -17624,4 +17626,10 @@ const char* View::SourceSubstitution( const char* srcFile ) const return res.c_str(); } +void View::SortThreads() { + std::sort( m_threadOrder.begin(), m_threadOrder.end(), + []( const ThreadData *a, const ThreadData *b ) { + return a->id < b->id; + } ); +} } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 84e3abd3..be7d4415 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -283,6 +283,7 @@ private: void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map& data, int64_t& ztime, const ZoneEvent& zone ); void SetPlaybackFrame( uint32_t idx ); + void SortThreads(); unordered_flat_map m_visData; unordered_flat_map m_visibleMsgThread;