diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 067af444b4d..6ab22a9b19f 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -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); diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp index e67f6bd3724..6711229e490 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp @@ -26,6 +26,8 @@ #include "qmlprofilernotesmodel.h" #include "qmlprofilerdatamodel.h" +#include + 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 ¬e) { + 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) diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h index dc3493ce17d..e6cb2287440 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.h +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.h @@ -38,7 +38,7 @@ public: QmlProfilerNotesModel(QObject *parent); void loadData(); - void saveData(); + void saveData(qint64 startTime, qint64 endTime); const QVector ¬es() const; void setNotes(const QVector ¬es);