diff --git a/src/SeerParallelStacksCommon.cpp b/src/SeerParallelStacksCommon.cpp index f19a7c3..4927dea 100644 --- a/src/SeerParallelStacksCommon.cpp +++ b/src/SeerParallelStacksCommon.cpp @@ -144,22 +144,27 @@ QString SeerParallelStacksThread::toString() const { return result; } -static std::shared_ptr buildImpl( QVector& threadPtrs, const QString& currentFunction, int depth) { +static std::shared_ptr buildImpl(const QVector& threads, const QString& currentFunction, int depth) { auto node = std::make_shared(); node->depth = depth; node->function = currentFunction; - node->threads = threadPtrs; + node->threads = threads; // Group threads by the function at position [-depth-1] (bottom-up). - QMap> functionThreads; + QMap> functionThreads; + int level = -depth - 1; - for (SeerParallelStacksThread* t : threadPtrs) { - int idx = t->frames().size() + level; // convert negative index - if (idx < 0 || idx >= t->frames().size()) + for (const SeerParallelStacksThread& t : threads) { + int idx = t.frames().size() + level; // convert negative index + + if (idx < 0 || idx >= t.frames().size()) { continue; - const QString& fn = t->frames()[idx].function(); + } + + const QString& fn = t.frames()[idx].function(); + functionThreads[fn].append(t); } @@ -171,16 +176,9 @@ static std::shared_ptr buildImpl( QVector SeerParallelStacksBuildParallelStacks(QVector& threads) { +std::shared_ptr SeerParallelStacksBuildParallelStacks(const QVector& threads) { - QVector ptrs; - ptrs.reserve(threads.size()); - - for (auto& t : threads) { - ptrs.append(&t); - } - - return buildImpl(ptrs, QString(), 0); + return buildImpl(threads, QString(), 0); } // --------------------------------------------------------------- @@ -192,8 +190,8 @@ std::shared_ptr SeerParallelStacksFillStack(const std:: stack->threadCount = static_cast(node->threads.size()); // Collect thread IDs for this node - for (const SeerParallelStacksThread* t : node->threads) { - stack->threadIds.append(t->id()); + for (const SeerParallelStacksThread& t : node->threads) { + stack->threadIds.append(t.id()); } if (!node->function.isEmpty()) { diff --git a/src/SeerParallelStacksCommon.h b/src/SeerParallelStacksCommon.h index 3502740..d3f1486 100644 --- a/src/SeerParallelStacksCommon.h +++ b/src/SeerParallelStacksCommon.h @@ -75,7 +75,7 @@ typedef QVector SeerParallelStacksThreads; struct SeerParallelStacksStackNode { QString function; // empty == root int depth = 0; - QVector threads; // non-owning pointers + QVector threads; QVector> children; }; @@ -88,6 +88,6 @@ struct SeerParallelStacksStack { int threadCount = 0; }; -std::shared_ptr SeerParallelStacksBuildParallelStacks (QVector& threads); // Build the parallel-stacks tree from a flat list of threads. +std::shared_ptr SeerParallelStacksBuildParallelStacks (const QVector& threads); // Build the parallel-stacks tree from a flat list of threads. std::shared_ptr SeerParallelStacksFillStack (const std::shared_ptr& node); diff --git a/src/SeerParallelStacksGraphicsView.cpp b/src/SeerParallelStacksGraphicsView.cpp index 7f6a8e9..970a8fb 100644 --- a/src/SeerParallelStacksGraphicsView.cpp +++ b/src/SeerParallelStacksGraphicsView.cpp @@ -561,7 +561,7 @@ SeerParallelStacksPopupTableWidget::SeerParallelStacksPopupTableWidget(QWidget* _table->viewport()->setMouseTracking(true); _table->horizontalHeader()->setStretchLastSection(true); _table->verticalHeader()->setVisible(false); - _table->setEditTriggers(QAbstractItemView::DoubleClicked); // NoEditTriggers + _table->setEditTriggers(QAbstractItemView::NoEditTriggers); _table->setSelectionBehavior(QAbstractItemView::SelectRows); _table->setFrameShape(QFrame::NoFrame); // outer QFrame provides the border _table->resizeColumnToContents(0); diff --git a/src/SeerParallelStacksVisualizerWidget.cpp b/src/SeerParallelStacksVisualizerWidget.cpp index 0ba9c04..f1ecdf0 100644 --- a/src/SeerParallelStacksVisualizerWidget.cpp +++ b/src/SeerParallelStacksVisualizerWidget.cpp @@ -260,9 +260,7 @@ void SeerParallelStacksVisualizerWidget::createDirectedGraph() { } // Build parallel-stacks tree - QVector local = _threads; // mutable copy for ptr stability - - auto root = SeerParallelStacksBuildParallelStacks(local); + auto root = SeerParallelStacksBuildParallelStacks(_threads); auto stack = SeerParallelStacksFillStack(root); graphicsView->setStack(stack);