diff options
-rw-r--r-- | src/plugins/qmlprofiler/flamegraphmodel.cpp | 36 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/flamegraphmodel.h | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/flamegraphview.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml | 7 |
4 files changed, 39 insertions, 14 deletions
diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index 843c771c74..ca7e690aee 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -38,6 +38,11 @@ namespace QmlProfiler { namespace Internal { +static inline quint64 supportedFeatures() +{ + return Constants::QML_JS_RANGE_FEATURES | (1ULL << ProfileMemory); +} + FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager, QObject *parent) : QAbstractItemModel(parent) { @@ -51,8 +56,9 @@ FlameGraphModel::FlameGraphModel(QmlProfilerModelManager *modelManager, connect(modelManager->notesModel(), &Timeline::TimelineNotesModel::changed, this, [this](int typeId, int, int){loadNotes(typeId, true);}); m_modelId = modelManager->registerModelProxy(); + m_acceptedFeatures = supportedFeatures(); - modelManager->announceFeatures(Constants::QML_JS_RANGE_FEATURES | 1 << ProfileMemory, + modelManager->announceFeatures(m_acceptedFeatures, [this](const QmlEvent &event, const QmlEventType &type) { loadEvent(event, type); }, [this](){ @@ -98,7 +104,8 @@ void FlameGraphModel::loadNotes(int typeIndex, bool emitSignal) void FlameGraphModel::loadEvent(const QmlEvent &event, const QmlEventType &type) { - Q_UNUSED(type); + if (!(m_acceptedFeatures & (1ULL << type.feature()))) + return; if (m_stackBottom.children.isEmpty()) beginResetModel(); @@ -150,6 +157,31 @@ void FlameGraphModel::onModelManagerStateChanged() clear(); } +void FlameGraphModel::restrictToFeatures(quint64 visibleFeatures) +{ + visibleFeatures = visibleFeatures & supportedFeatures(); + if (visibleFeatures == m_acceptedFeatures) + return; + + m_acceptedFeatures = visibleFeatures; + if (m_modelManager->state() != QmlProfilerModelManager::Done) + return; + + clear(); + beginResetModel(); + if (!m_modelManager->replayEvents(m_modelManager->traceTime()->startTime(), + m_modelManager->traceTime()->endTime(), + std::bind(&FlameGraphModel::loadEvent, + this, std::placeholders::_1, + std::placeholders::_2))) { + emit m_modelManager->error(tr("Could not re-read events from temporary trace file.")); + endResetModel(); + clear(); + } else { + finalize(); + } +} + static QString nameForType(RangeType typeNumber) { switch (typeNumber) { diff --git a/src/plugins/qmlprofiler/flamegraphmodel.h b/src/plugins/qmlprofiler/flamegraphmodel.h index 9fcc6e674c..587de41cf7 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.h +++ b/src/plugins/qmlprofiler/flamegraphmodel.h @@ -91,6 +91,7 @@ public slots: void loadEvent(const QmlEvent &event, const QmlEventType &type); void finalize(); void onModelManagerStateChanged(); + void restrictToFeatures(quint64 visibleFeatures); void loadNotes(int typeId, bool emitSignal); void clear(); @@ -105,6 +106,7 @@ private: FlameGraphData *m_callStackTop; FlameGraphData *m_compileStackTop; + quint64 m_acceptedFeatures; int m_modelId; QmlProfilerModelManager *m_modelManager; diff --git a/src/plugins/qmlprofiler/flamegraphview.cpp b/src/plugins/qmlprofiler/flamegraphview.cpp index 12cffd84d3..d26d4747a3 100644 --- a/src/plugins/qmlprofiler/flamegraphview.cpp +++ b/src/plugins/qmlprofiler/flamegraphview.cpp @@ -80,13 +80,7 @@ void FlameGraphView::selectByTypeId(int typeIndex) void FlameGraphView::onVisibleFeaturesChanged(quint64 features) { - int rangeTypeMask = 0; - for (int rangeType = 0; rangeType < MaximumRangeType; ++rangeType) { - if (features & (1ULL << featureFromRangeType(RangeType(rangeType)))) - rangeTypeMask |= (1 << rangeType); - } - if (m_content->rootObject()) - m_content->rootObject()->setProperty("visibleRangeTypes", rangeTypeMask); + m_model->restrictToFeatures(features); } void FlameGraphView::contextMenuEvent(QContextMenuEvent *ev) diff --git a/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml b/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml index 2de3ec9422..34bca26cfa 100644 --- a/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml +++ b/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml @@ -36,7 +36,6 @@ ScrollView { signal gotoSourceLocation(string filename, int line, int column) property int selectedTypeId: -1 - property int visibleRangeTypes: -1 property int sizeRole: QmlProfilerFlameGraphModel.DurationRole readonly property var trRoleNames: [ @@ -86,11 +85,9 @@ ScrollView { property int typeId: FlameGraph.data(QmlProfilerFlameGraphModel.TypeIdRole) || -1 property bool isBindingLoop: parent.checkBindingLoop(typeId) - property bool rangeTypeVisible: - root.visibleRangeTypes & (1 << FlameGraph.data(QmlProfilerFlameGraphModel.RangeTypeRole)) - itemHeight: rangeTypeVisible ? flamegraph.delegateHeight : 0 - isSelected: typeId !== -1 && typeId === root.selectedTypeId && rangeTypeVisible + itemHeight: flamegraph.delegateHeight + isSelected: typeId !== -1 && typeId === root.selectedTypeId borderColor: { if (isSelected) |