diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index 74eb70793a144c06e42d94e48e32e047ddb38e72..fe8d758d056bd8e1194d8a22a98219eb2b1a7b7e 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -44,7 +44,9 @@ FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager, { m_modelManager = modelManager; m_callStack.append(QmlEvent()); - m_stackTop = &m_stackBottom; + m_compileStack.append(QmlEvent()); + m_callStackTop = &m_stackBottom; + m_compileStackTop = &m_stackBottom; connect(modelManager, &QmlProfilerModelManager::stateChanged, this, &FlameGraphModel::onModelManagerStateChanged); connect(modelManager->notesModel(), &Timeline::TimelineNotesModel::changed, @@ -64,8 +66,11 @@ void FlameGraphModel::clear() beginResetModel(); m_stackBottom = FlameGraphData(0, -1, 1); m_callStack.clear(); + m_compileStack.clear(); m_callStack.append(QmlEvent()); - m_stackTop = &m_stackBottom; + m_compileStack.append(QmlEvent()); + m_callStackTop = &m_stackBottom; + m_compileStackTop = &m_stackBottom; m_typeIdsWithNotes.clear(); endResetModel(); } @@ -99,16 +104,20 @@ void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type) if (m_stackBottom.children.isEmpty()) beginResetModel(); - const QmlEvent *potentialParent = &(m_callStack.top()); + const bool isCompiling = (type.rangeType() == Compiling); + QStack<QmlEvent> &stack = isCompiling ? m_compileStack : m_callStack; + FlameGraphData *&stackTop = isCompiling ? m_compileStackTop : m_callStackTop; + + const QmlEvent *potentialParent = &(stack.top()); if (event.rangeStage() == RangeEnd) { - m_stackTop->duration += event.timestamp() - potentialParent->timestamp(); - m_callStack.pop(); - m_stackTop = m_stackTop->parent; - potentialParent = &(m_callStack.top()); + stackTop->duration += event.timestamp() - potentialParent->timestamp(); + stack.pop(); + stackTop = stackTop->parent; + potentialParent = &(stack.top()); } else { QTC_ASSERT(event.rangeStage() == RangeStart, return); - m_callStack.push(event); - m_stackTop = pushChild(m_stackTop, event); + stack.push(event); + stackTop = pushChild(stackTop, event); } } diff --git a/src/plugins/qmlprofiler/flamegraphmodel.h b/src/plugins/qmlprofiler/flamegraphmodel.h index b01cd5fa233441fe3b142fb29cd0413530f7f958..f4092bf437ef431fbb3d87be52e0bed6d6d71930 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.h +++ b/src/plugins/qmlprofiler/flamegraphmodel.h @@ -102,8 +102,10 @@ private: // used by binding loop detection QStack<QmlEvent> m_callStack; + QStack<QmlEvent> m_compileStack; FlameGraphData m_stackBottom; - FlameGraphData *m_stackTop; + FlameGraphData *m_callStackTop; + FlameGraphData *m_compileStackTop; int m_modelId; QmlProfilerModelManager *m_modelManager;