From 561841b93b9335cb3fda6d846cbe873a0517d359 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 4 Jul 2016 09:52:11 +0200 Subject: [PATCH] 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: Christian Kandeler Reviewed-by: Christian Stenger Reviewed-by: Ulf Hermann --- src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp | 4 ++-- src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp | 10 ++++++++-- src/plugins/qmlprofiler/qmlprofilernotesmodel.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) 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);