forked from qt-creator/qt-creator
QmlProfiler: manage receiving trace after app stopped
Change-Id: I97409748ebac3ee8af3690f2d84d3038638a3419 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -286,6 +286,8 @@ void QmlProfilerClientManager::connectionStateChanged()
|
|||||||
{
|
{
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput)
|
||||||
qWarning("QML Profiler: disconnected");
|
qWarning("QML Profiler: disconnected");
|
||||||
|
disconnectClient();
|
||||||
|
emit connectionClosed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QAbstractSocket::HostLookupState:
|
case QAbstractSocket::HostLookupState:
|
||||||
|
@@ -59,6 +59,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectionFailed();
|
void connectionFailed();
|
||||||
|
void connectionClosed();
|
||||||
|
|
||||||
// data
|
// data
|
||||||
void addRangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation);
|
void addRangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation);
|
||||||
|
@@ -216,10 +216,9 @@ void QmlProfilerEngine::stop()
|
|||||||
cancelProcess();
|
cancelProcess();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QmlProfilerStateManager::AppKilled : {
|
case QmlProfilerStateManager::AppDying :
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
// valid, but no further action is needed
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
qDebug() << tr("Unexpected engine stop from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
|
qDebug() << tr("Unexpected engine stop from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
|
||||||
break;
|
break;
|
||||||
@@ -232,18 +231,16 @@ void QmlProfilerEngine::processEnded()
|
|||||||
|
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
case QmlProfilerStateManager::AppRunning : {
|
case QmlProfilerStateManager::AppRunning : {
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
AnalyzerManager::stopTool();
|
AnalyzerManager::stopTool();
|
||||||
|
|
||||||
emit finished();
|
emit finished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QmlProfilerStateManager::AppStopped :
|
case QmlProfilerStateManager::AppStopped :
|
||||||
// fallthrough
|
case QmlProfilerStateManager::AppKilled :
|
||||||
case QmlProfilerStateManager::AppKilled : {
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
qDebug() << tr("Process died unexpectedly from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
|
qDebug() << tr("Process died unexpectedly from state %1 in %2:%3").arg(d->m_profilerState->currentStateAsString(), QString(__FILE__), QString::number(__LINE__));
|
||||||
break;
|
break;
|
||||||
@@ -260,7 +257,7 @@ void QmlProfilerEngine::cancelProcess()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QmlProfilerStateManager::AppRunning : {
|
case QmlProfilerStateManager::AppRunning : {
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -298,7 +295,7 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
|
|||||||
infoBox->show();
|
infoBox->show();
|
||||||
|
|
||||||
// KILL
|
// KILL
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
AnalyzerManager::stopTool();
|
AnalyzerManager::stopTool();
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,7 @@ inline QString stringForState(int state) {
|
|||||||
case QmlProfilerStateManager::AppStopRequested: return QString("AppStopRequested");
|
case QmlProfilerStateManager::AppStopRequested: return QString("AppStopRequested");
|
||||||
case QmlProfilerStateManager::AppReadyToStop: return QString("AppReadyToStop");
|
case QmlProfilerStateManager::AppReadyToStop: return QString("AppReadyToStop");
|
||||||
case QmlProfilerStateManager::AppStopped: return QString("AppStopped");
|
case QmlProfilerStateManager::AppStopped: return QString("AppStopped");
|
||||||
|
case QmlProfilerStateManager::AppDying: return QString("AppDying");
|
||||||
case QmlProfilerStateManager::AppKilled: return QString("AppKilled");
|
case QmlProfilerStateManager::AppKilled: return QString("AppKilled");
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@@ -108,7 +109,9 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
|||||||
QTC_ASSERT(d->m_currentState != newState, /**/);
|
QTC_ASSERT(d->m_currentState != newState, /**/);
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case Idle:
|
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;
|
break;
|
||||||
case AppStarting:
|
case AppStarting:
|
||||||
QTC_ASSERT(d->m_currentState == Idle, /**/);
|
QTC_ASSERT(d->m_currentState == Idle, /**/);
|
||||||
@@ -123,11 +126,14 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
|
|||||||
QTC_ASSERT(d->m_currentState == AppStopRequested, /**/);
|
QTC_ASSERT(d->m_currentState == AppStopRequested, /**/);
|
||||||
break;
|
break;
|
||||||
case AppStopped:
|
case AppStopped:
|
||||||
QTC_ASSERT(d->m_currentState == AppReadyToStop, /**/);
|
QTC_ASSERT(d->m_currentState == AppReadyToStop ||
|
||||||
|
d->m_currentState == AppDying, /**/);
|
||||||
break;
|
break;
|
||||||
case AppKilled:
|
case AppDying:
|
||||||
QTC_ASSERT(d->m_currentState == AppRunning, /**/);
|
QTC_ASSERT(d->m_currentState == AppRunning, /**/);
|
||||||
break;
|
break;
|
||||||
|
case AppKilled:
|
||||||
|
QTC_ASSERT(d->m_currentState == AppDying, /**/);
|
||||||
default:
|
default:
|
||||||
qDebug() << tr("Switching to unknown state in %1:%2").arg(QString(__FILE__), QString::number(__LINE__));
|
qDebug() << tr("Switching to unknown state in %1:%2").arg(QString(__FILE__), QString::number(__LINE__));
|
||||||
break;
|
break;
|
||||||
|
@@ -49,6 +49,7 @@ public:
|
|||||||
AppStopRequested,
|
AppStopRequested,
|
||||||
AppReadyToStop,
|
AppReadyToStop,
|
||||||
AppStopped,
|
AppStopped,
|
||||||
|
AppDying,
|
||||||
AppKilled
|
AppKilled
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -148,6 +148,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
|||||||
|
|
||||||
d->m_profilerConnections = new QmlProfilerClientManager(this);
|
d->m_profilerConnections = new QmlProfilerClientManager(this);
|
||||||
d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState);
|
d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState);
|
||||||
|
connect(d->m_profilerConnections, SIGNAL(connectionClosed()), this, SLOT(clientsDisconnected()));
|
||||||
|
|
||||||
d->m_profilerDataModel = new QmlProfilerDataModel(this);
|
d->m_profilerDataModel = new QmlProfilerDataModel(this);
|
||||||
connect(d->m_profilerDataModel, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged()));
|
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);
|
d->m_projectFinder.setSysroot(sp.sysroot);
|
||||||
|
|
||||||
connect(engine, SIGNAL(processRunning(quint16)), d->m_profilerConnections, SLOT(connectClient(quint16)));
|
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()));
|
connect(d->m_profilerConnections, SIGNAL(connectionFailed()), engine, SLOT(cancelProcess()));
|
||||||
|
|
||||||
return engine;
|
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()
|
void QmlProfilerTool::profilerDataModelStateChanged()
|
||||||
{
|
{
|
||||||
switch (d->m_profilerDataModel->currentState()) {
|
switch (d->m_profilerDataModel->currentState()) {
|
||||||
@@ -667,9 +683,7 @@ void QmlProfilerTool::profilerStateChanged()
|
|||||||
{
|
{
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
case QmlProfilerStateManager::AppKilled : {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case QmlProfilerStateManager::Idle :
|
case QmlProfilerStateManager::Idle :
|
||||||
|
@@ -85,6 +85,7 @@ public slots:
|
|||||||
void profilerStateChanged();
|
void profilerStateChanged();
|
||||||
void clientRecordingChanged();
|
void clientRecordingChanged();
|
||||||
void serverRecordingChanged();
|
void serverRecordingChanged();
|
||||||
|
void clientsDisconnected();
|
||||||
|
|
||||||
void recordingButtonChanged(bool recording);
|
void recordingButtonChanged(bool recording);
|
||||||
void setRecording(bool recording);
|
void setRecording(bool recording);
|
||||||
|
Reference in New Issue
Block a user