diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-04-29 14:43:32 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-23 12:31:51 +0000 |
commit | 914e1e1fe1a9c2ec42f011b56fb3d8f37163d7df (patch) | |
tree | 078453955a738a21a9943df2bea1b5620a55ee9f /src/plugins/qmlprofiler/qmlprofilertracefile.cpp | |
parent | 4a1e5a637a08299bd94428fba233d985a63f4675 (diff) |
QmlProfiler: Use data replay feature for saving traces
This removes the last access to the master event list, which allows
us to also remove the accessor function.
Change-Id: I0e70c2eb23d2b11aa8b131c03eb3adfad1a9b9e7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilertracefile.cpp')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertracefile.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index e726448303..8a2d18880a 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -504,11 +504,9 @@ void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint6 m_measuredTime = measuredTime; } -void QmlProfilerFileWriter::setData(const QVector<QmlEventType> &types, - const QVector<QmlEvent> &events) +void QmlProfilerFileWriter::setData(const QmlProfilerDataModel *model) { - m_eventTypes = types; - m_events = events; + m_model = model; } void QmlProfilerFileWriter::setNotes(const QVector<QmlNote> ¬es) @@ -524,8 +522,8 @@ void QmlProfilerFileWriter::setFuture(QFutureInterface<void> *future) void QmlProfilerFileWriter::save(QIODevice *device) { if (m_future) { - m_future->setProgressRange(0, - qMax(m_eventTypes.size() + m_events.size() + m_notes.size(), 1)); + m_future->setProgressRange( + 0, qMax(m_model->eventTypes().size() + m_model->count() + m_notes.size(), 1)); m_future->setProgressValue(0); m_newProgressValue = 0; } @@ -544,11 +542,12 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeStartElement(_("eventData")); stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime)); - for (int typeIndex = 0; typeIndex < m_eventTypes.size(); ++typeIndex) { + const QVector<QmlEventType> &eventTypes = m_model->eventTypes(); + for (int typeIndex = 0; typeIndex < eventTypes.size(); ++typeIndex) { if (isCanceled()) return; - const QmlEventType &type = m_eventTypes[typeIndex]; + const QmlEventType &type = eventTypes[typeIndex]; stream.writeStartElement(_("event")); stream.writeAttribute(_("index"), QString::number(typeIndex)); @@ -596,15 +595,14 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeStartElement(_("profilerDataModel")); QStack<QmlEvent> stack; - for (int rangeIndex = 0; rangeIndex < m_events.size(); ++rangeIndex) { + m_model->replayEvents(-1, -1, [this, &stack, &stream](const QmlEvent &event, + const QmlEventType &type) { if (isCanceled()) return; - const QmlEvent &event = m_events[rangeIndex]; - const QmlEventType &type = m_eventTypes[event.typeIndex()]; if (type.rangeType != MaximumRangeType && event.rangeStage() == RangeStart) { stack.push(event); - continue; + return; } stream.writeStartElement(_("range")); @@ -666,7 +664,7 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeEndElement(); incrementProgress(); - } + }); stream.writeEndElement(); // profilerDataModel stream.writeStartElement(_("noteData")); |