From 773f978bdc36fee78dcd168a0df9073a6c242994 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Tue, 2 Aug 2016 22:22:41 +0300 Subject: [PATCH] (ProfTreeWidget) Displaying thread names in the tree --- profiler_gui/blocks_tree_widget.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/profiler_gui/blocks_tree_widget.cpp b/profiler_gui/blocks_tree_widget.cpp index cb24685..0b0e2c8 100644 --- a/profiler_gui/blocks_tree_widget.cpp +++ b/profiler_gui/blocks_tree_widget.cpp @@ -300,12 +300,21 @@ size_t ProfTreeWidget::setTreeInternal(const unsigned int _blocksNumber, const t const QSignalBlocker b(this); for (const auto& threadTree : _blocksTree) { - auto item = new ProfTreeWidgetItem(&threadTree.second); - item->setText(COL_NAME, QString("Thread %1").arg(threadTree.first)); + auto& block = threadTree.second; + auto item = new ProfTreeWidgetItem(&block); + + if (block.thread_name && block.thread_name[0] != 0) + { + item->setText(COL_NAME, QString("%1 Thread %2").arg(block.thread_name).arg(threadTree.first)); + } + else + { + item->setText(COL_NAME, QString("Thread %1").arg(threadTree.first)); + } m_items.push_back(item); - const auto children_items_number = setTreeInternal(threadTree.second.children, item, m_beginTime, finishtime + 1000000000, false); + const auto children_items_number = setTreeInternal(block.children, item, m_beginTime, finishtime + 1000000000, false); if (children_items_number > 0) { @@ -364,7 +373,16 @@ size_t ProfTreeWidget::setTreeInternal(const TreeBlocks& _blocks, ::profiler::ti else { thread_item = new ProfTreeWidgetItem(block.thread_tree); - thread_item->setText(COL_NAME, QString("Thread %1").arg(block.thread_id)); + + if (block.thread_tree->thread_name && block.thread_tree->thread_name[0] != 0) + { + thread_item->setText(COL_NAME, QString("%1 Thread %2").arg(block.thread_tree->thread_name).arg(block.thread_id)); + } + else + { + thread_item->setText(COL_NAME, QString("Thread %1").arg(block.thread_id)); + } + threadsMap.insert(::std::make_pair(block.thread_id, thread_item)); }