Skip to content

Commit 103f9ae

Browse files
authored
Show active thread first in stack trace view (#827). Fix #726
1 parent 755da79 commit 103f9ae

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

ui/threadframes.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
#include "threadframes.h"
18+
#include <algorithm>
1819

1920
FrameItem::~FrameItem()
2021
{
@@ -181,6 +182,20 @@ void ThreadFrameModel::updateRows(DebuggerController* controller)
181182
parents << rootItem;
182183

183184
std::vector<DebugThread> threads = controller->GetThreads();
185+
186+
// Sort threads so that the active thread appears first
187+
uint32_t activeThreadId = controller->GetActiveThread().m_tid;
188+
std::sort(threads.begin(), threads.end(), [activeThreadId](const DebugThread& a, const DebugThread& b) {
189+
// Active thread comes first, then sort by thread ID for consistent ordering
190+
bool aIsActive = (a.m_tid == activeThreadId);
191+
bool bIsActive = (b.m_tid == activeThreadId);
192+
193+
if (aIsActive && !bIsActive) return true;
194+
if (!aIsActive && bIsActive) return false;
195+
196+
return a.m_tid < b.m_tid;
197+
});
198+
184199
for (const DebugThread& thread : threads)
185200
{
186201
parents.last()->appendChild(new FrameItem(thread, parents.last()));

0 commit comments

Comments
 (0)