QmlProfiler: Sanitize the signal exchange between models a bit

The model manager should only set its state to 'Done' if all models are
actually done. When that is the case it can safely emit dataAvailable,
too, freeing us of the need to apply a heuristic to the progress
percentage. In order to have a unified interface to the completion of
model processing an abstract base class for QML and V8 models is
introduced.

Task-number: QTCREATORBUG-11466
Change-Id: Id89c7ef5e24004baab7f37ee5486b69e7611aee0
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-02-12 17:35:08 +01:00
parent 5d2654e4e4
commit 47ce17b1ba
15 changed files with 171 additions and 62 deletions

View File

@@ -216,8 +216,6 @@ void QmlProfilerModelManager::modelProxyCountUpdated(int proxyId, qint64 count,
d->progress += d->partialCounts[proxyId] / d->partialCounts.count();
emit progressChanged();
if (d->progress > 0.99)
emit dataAvailable();
}
qint64 QmlProfilerModelManager::estimatedProfilingTime() const
@@ -259,25 +257,37 @@ void QmlProfilerModelManager::addV8Event(int depth, const QString &function, con
void QmlProfilerModelManager::complete()
{
if (state() == QmlProfilerDataState::AcquiringData) {
switch (state()) {
case QmlProfilerDataState::ProcessingData:
setState(QmlProfilerDataState::Done);
emit dataAvailable();
break;
case QmlProfilerDataState::AcquiringData:
// If trace end time was not explicitly set, use the last event
if (d->traceTime->endTime() == 0)
d->traceTime->setEndTime(d->model->lastTimeMark());
setState(QmlProfilerDataState::ProcessingData);
d->model->complete();
d->v8Model->complete();
break;
case QmlProfilerDataState::Empty:
setState(QmlProfilerDataState::Done);
} else
if (state() == QmlProfilerDataState::Empty) {
setState(QmlProfilerDataState::Done);
} else
if (state() == QmlProfilerDataState::Done) {
// repeated Done states are ignored
} else {
break;
case QmlProfilerDataState::Done:
break;
default:
emit error(tr("Unexpected complete signal in data model."));
break;
}
}
void QmlProfilerModelManager::modelProcessingDone()
{
Q_ASSERT(state() == QmlProfilerDataState::ProcessingData);
if (d->model->processingDone() && d->v8Model->processingDone())
complete();
}
void QmlProfilerModelManager::save(const QString &filename)
{
QFile file(filename);