Commit ba9c802e authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlProfiler: manage receiving trace after app stopped



Change-Id: I97409748ebac3ee8af3690f2d84d3038638a3419
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 5bf0280b
......@@ -286,6 +286,8 @@ void QmlProfilerClientManager::connectionStateChanged()
{
if (QmlProfilerPlugin::debugOutput)
qWarning("QML Profiler: disconnected");
disconnectClient();
emit connectionClosed();
break;
}
case QAbstractSocket::HostLookupState:
......
......@@ -59,6 +59,7 @@ public:
signals:
void connectionFailed();
void connectionClosed();
// data
void addRangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation);
......
......@@ -216,10 +216,9 @@ void QmlProfilerEngine::stop()
cancelProcess();
break;
}
case QmlProfilerStateManager::AppKilled : {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
case QmlProfilerStateManager::AppDying :
// valid, but no further action is needed
break;
}
default:
qDebug() << tr("Unexpected engine stop from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
break;
......@@ -232,18 +231,16 @@ void QmlProfilerEngine::processEnded()
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppRunning : {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
AnalyzerManager::stopTool();
emit finished();
break;
}
case QmlProfilerStateManager::AppStopped :
// fallthrough
case QmlProfilerStateManager::AppKilled : {
case QmlProfilerStateManager::AppKilled :
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
break;
}
default:
qDebug() << tr("Process died unexpectedly from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
break;
......@@ -260,7 +257,7 @@ void QmlProfilerEngine::cancelProcess()
break;
}
case QmlProfilerStateManager::AppRunning : {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
break;
}
default: {
......@@ -298,7 +295,7 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
infoBox->show();
// KILL
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
AnalyzerManager::stopTool();
emit finished();
}
......
......@@ -49,6 +49,7 @@ inline QString stringForState(int state) {
case QmlProfilerStateManager::AppStopRequested: return QString("AppStopRequested");
case QmlProfilerStateManager::AppReadyToStop: return QString("AppReadyToStop");
case QmlProfilerStateManager::AppStopped: return QString("AppStopped");
case QmlProfilerStateManager::AppDying: return QString("AppDying");
case QmlProfilerStateManager::AppKilled: return QString("AppKilled");
default: break;
}
......@@ -108,7 +109,9 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
QTC_ASSERT(d->m_currentState != newState, /**/);
switch (newState) {
case Idle:
QTC_ASSERT(d->m_currentState == AppStarting || d->m_currentState == AppStopped || d->m_currentState == AppKilled, /**/);
QTC_ASSERT(d->m_currentState == AppStarting ||
d->m_currentState == AppStopped ||
d->m_currentState == AppKilled, /**/);
break;
case AppStarting:
QTC_ASSERT(d->m_currentState == Idle, /**/);
......@@ -123,11 +126,14 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
QTC_ASSERT(d->m_currentState == AppStopRequested, /**/);
break;
case AppStopped:
QTC_ASSERT(d->m_currentState == AppReadyToStop, /**/);
QTC_ASSERT(d->m_currentState == AppReadyToStop ||
d->m_currentState == AppDying, /**/);
break;
case AppKilled:
case AppDying:
QTC_ASSERT(d->m_currentState == AppRunning, /**/);
break;
case AppKilled:
QTC_ASSERT(d->m_currentState == AppDying, /**/);
default:
qDebug() << tr("Switching to unknown state in %1:%2").arg(QString(__FILE__), QString::number(__LINE__));
break;
......
......@@ -49,6 +49,7 @@ public:
AppStopRequested,
AppReadyToStop,
AppStopped,
AppDying,
AppKilled
};
......
......@@ -148,6 +148,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
d->m_profilerConnections = new QmlProfilerClientManager(this);
d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState);
connect(d->m_profilerConnections, SIGNAL(connectionClosed()), this, SLOT(clientsDisconnected()));
d->m_profilerDataModel = new QmlProfilerDataModel(this);
connect(d->m_profilerDataModel, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged()));
......@@ -302,7 +303,6 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
d->m_projectFinder.setSysroot(sp.sysroot);
connect(engine, SIGNAL(processRunning(quint16)), d->m_profilerConnections, SLOT(connectClient(quint16)));
connect(engine, SIGNAL(finished()), d->m_profilerConnections, SLOT(disconnectClient()));
connect(d->m_profilerConnections, SIGNAL(connectionFailed()), engine, SLOT(cancelProcess()));
return engine;
......@@ -612,6 +612,22 @@ void QmlProfilerTool::showLoadDialog()
}
}
void QmlProfilerTool::clientsDisconnected()
{
// If the application stopped by itself, check if we have all the data
if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) {
if (d->m_profilerDataModel->currentState() == QmlProfilerDataModel::AcquiringData)
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
else
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped);
// ... and return to the "base" state
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
}
// If the connection is closed while the app is still running, no special action is needed
}
void QmlProfilerTool::profilerDataModelStateChanged()
{
switch (d->m_profilerDataModel->currentState()) {
......@@ -667,9 +683,7 @@ void QmlProfilerTool::profilerStateChanged()
{
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppKilled : {
if (d->m_profilerDataModel->currentState() == QmlProfilerDataModel::AcquiringData) {
showNonmodalWarning(tr("Application finished before loading profiled data.\n Please use the stop button instead."));
}
showNonmodalWarning(tr("Application finished before loading profiled data.\n Please use the stop button instead."));
break;
}
case QmlProfilerStateManager::Idle :
......
......@@ -85,6 +85,7 @@ public slots:
void profilerStateChanged();
void clientRecordingChanged();
void serverRecordingChanged();
void clientsDisconnected();
void recordingButtonChanged(bool recording);
void setRecording(bool recording);
......
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