Commit 561841b9 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Use current restriction range when saving notes

We don't want to clear notes outside the current restriction as those
are still valid and need to be available for later reloading.

Change-Id: If3e75ff2b2ab9a93578c5ca63f1b4a2f539dc802
Task-number: QTCREATORBUG-16542
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
Reviewed-by: Ulf Hermann's avatarUlf Hermann <ulf.hermann@qt.io>
parent 268fea1c
......@@ -314,7 +314,7 @@ void QmlProfilerModelManager::save(const QString &filename)
return;
}
d->notesModel->saveData();
d->notesModel->saveData(d->traceTime->startTime(), d->traceTime->endTime());
QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this);
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
......@@ -442,7 +442,7 @@ void QmlProfilerModelManager::clear()
void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
{
d->notesModel->saveData();
d->notesModel->saveData(d->traceTime->startTime(), d->traceTime->endTime());
setState(ClearingData);
setVisibleFeatures(0);
......
......@@ -26,6 +26,8 @@
#include "qmlprofilernotesmodel.h"
#include "qmlprofilerdatamodel.h"
#include <utils/algorithm.h>
namespace QmlProfiler {
QmlProfilerNotesModel::QmlProfilerNotesModel(QObject *parent) : TimelineNotesModel(parent)
......@@ -74,9 +76,13 @@ void QmlProfilerNotesModel::loadData()
emit changed(-1, -1, -1);
}
void QmlProfilerNotesModel::saveData()
void QmlProfilerNotesModel::saveData(qint64 startTime, qint64 endTime)
{
m_notes.clear();
// Keep notes that are outside the given range, overwrite the ones inside the range.
m_notes = Utils::filtered(m_notes, [startTime, endTime](const QmlNote &note) {
return note.startTime() > endTime || note.startTime() + note.duration() < startTime;
});
for (int i = 0; i < count(); ++i) {
const Timeline::TimelineModel *model = timelineModelByModelId(timelineModel(i));
if (!model)
......
......@@ -38,7 +38,7 @@ public:
QmlProfilerNotesModel(QObject *parent);
void loadData();
void saveData();
void saveData(qint64 startTime, qint64 endTime);
const QVector<QmlNote> &notes() const;
void setNotes(const QVector<QmlNote> &notes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment