QmlProfiler: Guard against the temporary trace file going away

If we cannot open a temporary file to cache a trace or retrieve a
previously cached trace, the QML profiler won't work correctly. Show
an error in this case.

Change-Id: I468d74d9c33033b9ad19501bccbd69a9fe164fed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2017-02-20 19:19:50 +01:00
parent 1ee8d0fb64
commit bf69eb9467
5 changed files with 56 additions and 24 deletions

View File

@@ -176,6 +176,10 @@ QmlProfilerModelManager::QmlProfilerModelManager(QObject *parent) :
d->textMarkModel = new QmlProfilerTextMarkModel(this);
connect(d->model, &QmlProfilerDataModel::allTypesLoaded,
this, &QmlProfilerModelManager::processingDone);
connect(d->model, &QmlProfilerDataModel::traceFileError,
this, [this]() {
emit error(tr("Could not open a temporary file for storing QML traces."));
});
}
QmlProfilerModelManager::~QmlProfilerModelManager()
@@ -543,12 +547,17 @@ void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
setVisibleFeatures(0);
startAcquiring();
d->model->replayEvents(startTime, endTime,
std::bind(&QmlProfilerModelManagerPrivate::dispatch, d,
std::placeholders::_1, std::placeholders::_2));
d->notesModel->setNotes(notes);
d->traceTime->restrictToRange(startTime, endTime);
acquiringDone();
if (!d->model->replayEvents(startTime, endTime,
std::bind(&QmlProfilerModelManagerPrivate::dispatch, d,
std::placeholders::_1, std::placeholders::_2))) {
emit error(tr("Could not re-read events from temporary trace file. "
"The trace data is lost."));
clear();
} else {
d->notesModel->setNotes(notes);
d->traceTime->restrictToRange(startTime, endTime);
acquiringDone();
}
}
bool QmlProfilerModelManager::isRestrictedToRange() const