diff options
author | Ulf Hermann <[email protected]> | 2014-02-12 17:35:08 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2014-02-18 14:43:52 +0100 |
commit | 47ce17b1ba82e396480c565dda6334fc58ed5cc3 (patch) | |
tree | 0eb79b6ce3801ef59b2b64555a89c13477a11068 /src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp | |
parent | 5d2654e4e4c6e4a2ca79ff9c6949e58472a9ae0f (diff) |
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 <[email protected]>
Reviewed-by: Kai Koehne <[email protected]>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp')
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 62751f3d222..abedd2700f4 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -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); |