mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 16:40:42 +08:00
Make table read-only, for now. Remove ptrs and make instances of
threads and frames. It may have fixed the segfault at close.
This commit is contained in:
@@ -144,22 +144,27 @@ QString SeerParallelStacksThread::toString() const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<SeerParallelStacksStackNode> buildImpl( QVector<SeerParallelStacksThread*>& threadPtrs, const QString& currentFunction, int depth) {
|
static std::shared_ptr<SeerParallelStacksStackNode> buildImpl(const QVector<SeerParallelStacksThread>& threads, const QString& currentFunction, int depth) {
|
||||||
|
|
||||||
auto node = std::make_shared<SeerParallelStacksStackNode>();
|
auto node = std::make_shared<SeerParallelStacksStackNode>();
|
||||||
node->depth = depth;
|
node->depth = depth;
|
||||||
node->function = currentFunction;
|
node->function = currentFunction;
|
||||||
node->threads = threadPtrs;
|
node->threads = threads;
|
||||||
|
|
||||||
// Group threads by the function at position [-depth-1] (bottom-up).
|
// Group threads by the function at position [-depth-1] (bottom-up).
|
||||||
QMap<QString, QVector<SeerParallelStacksThread*>> functionThreads;
|
QMap<QString, QVector<SeerParallelStacksThread>> functionThreads;
|
||||||
|
|
||||||
int level = -depth - 1;
|
int level = -depth - 1;
|
||||||
|
|
||||||
for (SeerParallelStacksThread* t : threadPtrs) {
|
for (const SeerParallelStacksThread& t : threads) {
|
||||||
int idx = t->frames().size() + level; // convert negative index
|
int idx = t.frames().size() + level; // convert negative index
|
||||||
if (idx < 0 || idx >= t->frames().size())
|
|
||||||
|
if (idx < 0 || idx >= t.frames().size()) {
|
||||||
continue;
|
continue;
|
||||||
const QString& fn = t->frames()[idx].function();
|
}
|
||||||
|
|
||||||
|
const QString& fn = t.frames()[idx].function();
|
||||||
|
|
||||||
functionThreads[fn].append(t);
|
functionThreads[fn].append(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,16 +176,9 @@ static std::shared_ptr<SeerParallelStacksStackNode> buildImpl( QVector<SeerParal
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SeerParallelStacksStackNode> SeerParallelStacksBuildParallelStacks(QVector<SeerParallelStacksThread>& threads) {
|
std::shared_ptr<SeerParallelStacksStackNode> SeerParallelStacksBuildParallelStacks(const QVector<SeerParallelStacksThread>& threads) {
|
||||||
|
|
||||||
QVector<SeerParallelStacksThread*> ptrs;
|
return buildImpl(threads, QString(), 0);
|
||||||
ptrs.reserve(threads.size());
|
|
||||||
|
|
||||||
for (auto& t : threads) {
|
|
||||||
ptrs.append(&t);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buildImpl(ptrs, QString(), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
@@ -192,8 +190,8 @@ std::shared_ptr<SeerParallelStacksStack> SeerParallelStacksFillStack(const std::
|
|||||||
stack->threadCount = static_cast<int>(node->threads.size());
|
stack->threadCount = static_cast<int>(node->threads.size());
|
||||||
|
|
||||||
// Collect thread IDs for this node
|
// Collect thread IDs for this node
|
||||||
for (const SeerParallelStacksThread* t : node->threads) {
|
for (const SeerParallelStacksThread& t : node->threads) {
|
||||||
stack->threadIds.append(t->id());
|
stack->threadIds.append(t.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node->function.isEmpty()) {
|
if (!node->function.isEmpty()) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ typedef QVector<SeerParallelStacksThread> SeerParallelStacksThreads;
|
|||||||
struct SeerParallelStacksStackNode {
|
struct SeerParallelStacksStackNode {
|
||||||
QString function; // empty == root
|
QString function; // empty == root
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
QVector<SeerParallelStacksThread*> threads; // non-owning pointers
|
QVector<SeerParallelStacksThread> threads;
|
||||||
QVector<std::shared_ptr<SeerParallelStacksStackNode>> children;
|
QVector<std::shared_ptr<SeerParallelStacksStackNode>> children;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,6 +88,6 @@ struct SeerParallelStacksStack {
|
|||||||
int threadCount = 0;
|
int threadCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::shared_ptr<SeerParallelStacksStackNode> SeerParallelStacksBuildParallelStacks (QVector<SeerParallelStacksThread>& threads); // Build the parallel-stacks tree from a flat list of threads.
|
std::shared_ptr<SeerParallelStacksStackNode> SeerParallelStacksBuildParallelStacks (const QVector<SeerParallelStacksThread>& threads); // Build the parallel-stacks tree from a flat list of threads.
|
||||||
std::shared_ptr<SeerParallelStacksStack> SeerParallelStacksFillStack (const std::shared_ptr<SeerParallelStacksStackNode>& node);
|
std::shared_ptr<SeerParallelStacksStack> SeerParallelStacksFillStack (const std::shared_ptr<SeerParallelStacksStackNode>& node);
|
||||||
|
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ SeerParallelStacksPopupTableWidget::SeerParallelStacksPopupTableWidget(QWidget*
|
|||||||
_table->viewport()->setMouseTracking(true);
|
_table->viewport()->setMouseTracking(true);
|
||||||
_table->horizontalHeader()->setStretchLastSection(true);
|
_table->horizontalHeader()->setStretchLastSection(true);
|
||||||
_table->verticalHeader()->setVisible(false);
|
_table->verticalHeader()->setVisible(false);
|
||||||
_table->setEditTriggers(QAbstractItemView::DoubleClicked); // NoEditTriggers
|
_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
_table->setFrameShape(QFrame::NoFrame); // outer QFrame provides the border
|
_table->setFrameShape(QFrame::NoFrame); // outer QFrame provides the border
|
||||||
_table->resizeColumnToContents(0);
|
_table->resizeColumnToContents(0);
|
||||||
|
|||||||
@@ -260,9 +260,7 @@ void SeerParallelStacksVisualizerWidget::createDirectedGraph() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build parallel-stacks tree
|
// Build parallel-stacks tree
|
||||||
QVector<SeerParallelStacksThread> local = _threads; // mutable copy for ptr stability
|
auto root = SeerParallelStacksBuildParallelStacks(_threads);
|
||||||
|
|
||||||
auto root = SeerParallelStacksBuildParallelStacks(local);
|
|
||||||
auto stack = SeerParallelStacksFillStack(root);
|
auto stack = SeerParallelStacksFillStack(root);
|
||||||
|
|
||||||
graphicsView->setStack(stack);
|
graphicsView->setStack(stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user