diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp index 29fd507207b9958943e1b614ce31d3e344eff024..946427a7235c246259156d75368c96076c679350 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp @@ -96,11 +96,7 @@ QmlProfilerClientManager::~QmlProfilerClientManager() void QmlProfilerClientManager::setModelManager(QmlProfilerModelManager *m) { - if (d->modelManager) - disconnect(this,SIGNAL(dataReadyForProcessing()), d->modelManager, SLOT(complete())); d->modelManager = m; - if (d->modelManager) - connect(this,SIGNAL(dataReadyForProcessing()), d->modelManager, SLOT(complete())); } void QmlProfilerClientManager::setFlushInterval(quint32 flushInterval) @@ -315,7 +311,8 @@ void QmlProfilerClientManager::qmlComplete(qint64 maximumTime) { d->modelManager->traceTime()->increaseEndTime(maximumTime); d->qmlDataReady = true; - emit dataReadyForProcessing(); + if (d->modelManager) + d->modelManager->acquiringDone(); // once complete is sent, reset the flags d->qmlDataReady = false; } diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h index 4f878b2485c7e1934412119a45e87d549e43cb92..9f7d3df3f710b233029602eabd474615775e1867 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h @@ -62,7 +62,6 @@ public: signals: void connectionFailed(); void connectionClosed(); - void dataReadyForProcessing(); public slots: void connectClient(quint16 port); diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 9e33df85e71101ba1aec6986d5eec42bcbf783a0..e29fd515486462198e7a6d26843d3dda048a0996 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -111,10 +111,12 @@ QmlProfilerDataModel::QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinde d->modelManager = parent; d->detailsRewriter = new QmlProfilerDetailsRewriter(this, fileFinder); d->modelId = d->modelManager->registerModelProxy(); - connect(d->detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)), - this, SLOT(detailsChanged(int,QString))); - connect(d->detailsRewriter, SIGNAL(eventDetailsChanged()), - this, SLOT(detailsDone())); + connect(d->detailsRewriter, &QmlProfilerDetailsRewriter::rewriteDetailsString, + this, &QmlProfilerDataModel::detailsChanged); + connect(d->detailsRewriter, &QmlProfilerDetailsRewriter::eventDetailsChanged, + this, &QmlProfilerDataModel::detailsDone); + connect(this, &QmlProfilerDataModel::requestReload, + d->detailsRewriter, &QmlProfilerDetailsRewriter::reloadDocuments); // The document loading is very expensive. d->modelManager->setProxyCountWeight(d->modelId, 4); @@ -155,7 +157,7 @@ void QmlProfilerDataModel::setData(qint64 traceStart, qint64 traceEnd, d->eventTypes = types; for (int id = 0; id < types.count(); ++id) d->eventTypeIds[types[id]] = id; - // Half the work is done. complete() will do the rest. + // Half the work is done. processData() will do the rest. d->modelManager->modelProxyCountUpdated(d->modelId, 1, 2); } @@ -215,7 +217,7 @@ inline static bool operator==(const QmlProfilerDataModel::QmlEventTypeData &type type1.location.filename == type2.location.filename; } -void QmlProfilerDataModel::complete() +void QmlProfilerDataModel::processData() { Q_D(QmlProfilerDataModel); // post-processing @@ -251,7 +253,7 @@ void QmlProfilerDataModel::complete() // Allow changed() event only after documents have been reloaded to avoid // unnecessary updates of child models. - d->detailsRewriter->reloadDocuments(); + emit requestReload(); } void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, @@ -313,7 +315,7 @@ void QmlProfilerDataModel::detailsDone() Q_D(QmlProfilerDataModel); emit changed(); d->modelManager->modelProxyCountUpdated(d->modelId, isEmpty() ? 0 : 1, 1); - d->modelManager->complete(); + d->modelManager->processingDone(); } } diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h index fee1b4bacca2f5aeae7da50091cdf3c7ee961f57..c86ca76f1ce811cb435fd505df52abb33533774c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.h +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.h @@ -81,11 +81,11 @@ public: void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventTypeData> &types, const QVector<QmlEventData> &events); void setNoteData(const QVector<QmlEventNoteData> ¬es); + void processData(); int count() const; void clear(); bool isEmpty() const; - void complete(); void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType, qint64 startTime, qint64 duration, const QString &data, const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2, @@ -94,6 +94,7 @@ public: signals: void changed(); + void requestReload(); protected slots: void detailsChanged(int requestId, const QString &newString); diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 12f6f12670d5f69c42b8eeda4ed5202e8eb092d7..726648970caf27f44724481c784ae4f8f6d48ea6 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -293,30 +293,19 @@ void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message, ndata1, ndata2, ndata3, ndata4, ndata5); } -void QmlProfilerModelManager::complete() +void QmlProfilerModelManager::acquiringDone() { - switch (state()) { - case ProcessingData: - // Load notes after the timeline models have been initialized. - d->notesModel->loadData(); - setState(Done); - emit loadFinished(); - break; - case AcquiringData: - // Make sure the trace fits into the time span. - d->traceTime->increaseEndTime(d->model->lastTimeMark()); - setState(ProcessingData); - d->model->complete(); - break; - case Empty: - setState(Done); - break; - case Done: - break; - default: - emit error(tr("Unexpected complete signal in data model.")); - break; - } + QTC_ASSERT(state() == AcquiringData, /**/); + setState(ProcessingData); + d->model->processData(); +} + +void QmlProfilerModelManager::processingDone() +{ + QTC_ASSERT(state() == ProcessingData, /**/); + d->notesModel->loadData(); + setState(Done); + emit loadFinished(); } void QmlProfilerModelManager::save(const QString &filename) @@ -369,10 +358,8 @@ void QmlProfilerModelManager::load(const QString &filename) setRecordedFeatures(reader.loadedFeatures()); file->close(); file->deleteLater(); - - // The completion step uses the old progress display widget for now. We need to do this in - // the main thread as it creates widgets. - QMetaObject::invokeMethod(this, "complete", Qt::QueuedConnection); + d->traceTime->increaseEndTime(d->model->lastTimeMark()); + acquiringDone(); }); Core::ProgressManager::addTask(result, tr("Loading Trace Data"), Constants::TASK_LOAD); diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h index 56f2328541145755b7cb21b02db98737d8508c18..19ab0e5f39a7669eede1909c921dc63e90a1b104 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h @@ -110,6 +110,9 @@ public: quint64 recordedFeatures() const; void setRecordedFeatures(quint64 features); + void acquiringDone(); + void processingDone(); + static const char *featureName(QmlDebug::ProfileFeature feature); signals: @@ -133,8 +136,6 @@ public slots: const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5); - void complete(); - void save(const QString &filename); void load(const QString &filename);