Commit fdbed834 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Refactor complete() methods



The complete() methods do something more specific. We should call them
by what they do. Also, we don't need to signal the finishing of data
acquisition via a signal and most of the postprocessing can happen in
the worker thread.

Change-Id: Iae986aefb8e7e7d4327c481d7a85325bbff7fa48
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 44750d04
......@@ -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;
}
......
......@@ -62,7 +62,6 @@ public:
signals:
void connectionFailed();
void connectionClosed();
void dataReadyForProcessing();
public slots:
void connectClient(quint16 port);
......
......@@ -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();
}
}
......@@ -81,11 +81,11 @@ public:
void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventTypeData> &types,
const QVector<QmlEventData> &events);
void setNoteData(const QVector<QmlEventNoteData> &notes);
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);
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment