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

QmlProfiler: Clean up the state widget



Ultimately we want this as jobs for the progress manager, but let's
get the logic right before. The state widget should not estimate
profiling times and it doesn't have to keep local copies of all the
state the model and state managers already have. Also, we need an
additional indication for "waiting for application to send data", as
that can take significant time.

Change-Id: I3677dea4b0561bc83a7bc3c196ce0854c5624f12
Task-number: QTCREATORBUG-12958
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 1caa899b
...@@ -322,11 +322,6 @@ const char *QmlProfilerModelManager::featureName(QmlDebug::ProfileFeature featur ...@@ -322,11 +322,6 @@ const char *QmlProfilerModelManager::featureName(QmlDebug::ProfileFeature featur
return ProfileFeatureNames[feature]; return ProfileFeatureNames[feature];
} }
void QmlProfilerModelManager::newTimeEstimation(qint64 estimation)
{
d->traceTime->increaseEndTime(d->traceTime->startTime() + estimation);
}
void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message, void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message,
QmlDebug::RangeType rangeType, QmlDebug::RangeType rangeType,
int detailType, int detailType,
......
...@@ -163,8 +163,6 @@ public slots: ...@@ -163,8 +163,6 @@ public slots:
void setFilename(const QString &filename); void setFilename(const QString &filename);
void load(); void load();
void newTimeEstimation(qint64 estimation);
private: private:
void setState(QmlProfilerDataState::State state); void setState(QmlProfilerDataState::State state);
......
...@@ -51,14 +51,6 @@ class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate ...@@ -51,14 +51,6 @@ class QmlProfilerStateWidget::QmlProfilerStateWidgetPrivate
QmlProfilerStateManager *m_profilerState; QmlProfilerStateManager *m_profilerState;
QmlProfilerModelManager *m_modelManager; QmlProfilerModelManager *m_modelManager;
bool isRecording;
bool appKilled;
bool emptyList;
bool traceAvailable;
bool loadingDone;
QTime profilingTimer;
qint64 estimatedProfilingTime;
}; };
QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateManager, QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateManager,
...@@ -84,22 +76,17 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan ...@@ -84,22 +76,17 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan
setLayout(layout); setLayout(layout);
// internal state
d->isRecording = false;
d->appKilled = false;
d->traceAvailable = false;
d->loadingDone = true;
d->emptyList = true;
// profiler state // profiler state
d->m_modelManager = modelManager; d->m_modelManager = modelManager;
connect(d->m_modelManager,SIGNAL(stateChanged()), this, SLOT(dataStateChanged())); connect(d->m_modelManager, &QmlProfilerModelManager::stateChanged,
connect(d->m_modelManager,SIGNAL(progressChanged()), this, SLOT(dataStateChanged())); this, &QmlProfilerStateWidget::updateDisplay);
connect(this, SIGNAL(newTimeEstimation(qint64)), d->m_modelManager, SLOT(newTimeEstimation(qint64))); connect(d->m_modelManager, &QmlProfilerModelManager::progressChanged,
this, &QmlProfilerStateWidget::updateDisplay);
d->m_profilerState = stateManager; d->m_profilerState = stateManager;
connect(d->m_profilerState,SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged,
connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), this, &QmlProfilerStateWidget::updateDisplay);
this, SLOT(profilerStateChanged())); connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
this, &QmlProfilerStateWidget::updateDisplay);
updateDisplay(); updateDisplay();
} }
...@@ -190,14 +177,8 @@ void QmlProfilerStateWidget::paintEvent(QPaintEvent *event) ...@@ -190,14 +177,8 @@ void QmlProfilerStateWidget::paintEvent(QPaintEvent *event)
void QmlProfilerStateWidget::showText(const QString &text, bool showProgress) void QmlProfilerStateWidget::showText(const QString &text, bool showProgress)
{ {
setVisible(true); setVisible(true);
if (showProgress) { if (showProgress)
if (d->isRecording) {
d->isRecording = false;
d->estimatedProfilingTime = d->profilingTimer.elapsed();
emit newTimeEstimation(d->estimatedProfilingTime);
}
d->progressBar->setValue(d->m_modelManager->progress() * 1000); d->progressBar->setValue(d->m_modelManager->progress() * 1000);
}
d->progressBar->setVisible(showProgress); d->progressBar->setVisible(showProgress);
d->text->setText(text); d->text->setText(text);
resize(300, 70); resize(300, 70);
...@@ -207,26 +188,28 @@ void QmlProfilerStateWidget::showText(const QString &text, bool showProgress) ...@@ -207,26 +188,28 @@ void QmlProfilerStateWidget::showText(const QString &text, bool showProgress)
void QmlProfilerStateWidget::updateDisplay() void QmlProfilerStateWidget::updateDisplay()
{ {
// When application is being profiled // When application is being profiled
if (d->isRecording) { if (d->m_profilerState->serverRecording()) {
showText(tr("Profiling application")); showText(tr("Profiling application"));
return; return;
} }
// When datamodel is acquiring data QmlProfilerDataState::State state = d->m_modelManager->state();
if (!d->loadingDone && !d->emptyList && !d->appKilled) { if (state == QmlProfilerDataState::Done || state == QmlProfilerDataState::Empty) {
showText(tr("Loading data"), true); // After profiling, there is an empty trace
return; if (d->m_modelManager->traceTime()->duration() > 0 &&
} (d->m_modelManager->isEmpty() || d->m_modelManager->progress() == 0)) {
showText(tr("No QML events recorded"));
// After profiling, there is an empty trace return;
if (d->traceAvailable && d->loadingDone && d->emptyList) { }
showText(tr("No QML events recorded")); } else if (d->m_modelManager->progress() != 0 && !d->m_modelManager->isEmpty()) {
// When datamodel is acquiring data
if (d->m_profilerState->currentState() != QmlProfilerStateManager::AppKilled)
showText(tr("Loading data"), true);
else // Application died before all data could be read
showText(tr("Application stopped before loading all data"), true);
return; return;
} } else if (state == QmlProfilerDataState::AcquiringData) {
showText(tr("Waiting for data"));
// Application died before all data could be read
if (!d->loadingDone && !d->emptyList && d->appKilled) {
showText(tr("Application stopped before loading all data"), true);
return; return;
} }
...@@ -235,35 +218,5 @@ void QmlProfilerStateWidget::updateDisplay() ...@@ -235,35 +218,5 @@ void QmlProfilerStateWidget::updateDisplay()
setVisible(false); setVisible(false);
} }
void QmlProfilerStateWidget::dataStateChanged()
{
// consider possible rounding errors
d->loadingDone = d->m_modelManager->state() == QmlProfilerDataState::Done ||
d->m_modelManager->state() == QmlProfilerDataState::Empty;
d->traceAvailable = d->m_modelManager->traceTime()->duration() > 0;
d->emptyList = d->m_modelManager->isEmpty() || d->m_modelManager->progress() == 0;
updateDisplay();
}
void QmlProfilerStateWidget::profilerStateChanged()
{
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppKilled)
d->appKilled = true;
else
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStarting)
d->appKilled = false;
if (d->m_profilerState->serverRecording()) {
d->profilingTimer.start();
d->isRecording = true;
} else if (d->isRecording) {
// estimated time in ns
d->estimatedProfilingTime = d->profilingTimer.elapsed() * 1e6;
emit newTimeEstimation(d->estimatedProfilingTime);
d->isRecording = false;
}
updateDisplay();
}
} }
} }
...@@ -50,13 +50,8 @@ public: ...@@ -50,13 +50,8 @@ public:
private slots: private slots:
void showText(const QString &text, bool showProgress = false); void showText(const QString &text, bool showProgress = false);
void updateDisplay(); void updateDisplay();
void dataStateChanged();
void profilerStateChanged();
void reposition(); void reposition();
signals:
void newTimeEstimation(qint64);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
......
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