summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@nokia.com>2012-05-08 15:14:11 +0200
committerChristiaan Janssen <christiaan.janssen@nokia.com>2012-05-09 11:19:46 +0200
commitba9c802e1eeb13dac0d6130eead8380a2ef98bf7 (patch)
treeb6a4b0c4c572ad89fdb521b7a56dd926bc0e01f6
parent5bf0280b2a534319f02edad0dfdd40f7bb80e7fd (diff)
downloadqt-creator-ba9c802e1eeb13dac0d6130eead8380a2ef98bf7.tar.gz
QmlProfiler: manage receiving trace after app stopped
Change-Id: I97409748ebac3ee8af3690f2d84d3038638a3419 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.h1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerengine.cpp15
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp12
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerstatemanager.h1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp22
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.h1
7 files changed, 38 insertions, 16 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
index 874c96e3a4..57f310327e 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
@@ -286,6 +286,8 @@ void QmlProfilerClientManager::connectionStateChanged()
{
if (QmlProfilerPlugin::debugOutput)
qWarning("QML Profiler: disconnected");
+ disconnectClient();
+ emit connectionClosed();
break;
}
case QAbstractSocket::HostLookupState:
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
index 591db020da..87f62c944c 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h
@@ -59,6 +59,7 @@ public:
signals:
void connectionFailed();
+ void connectionClosed();
// data
void addRangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation);
diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
index f6deeb961b..0e3b71dbc3 100644
--- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp
@@ -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();
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp b/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp
index 194e2cdf1c..dd60d33eca 100644
--- a/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerstatemanager.cpp
@@ -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;
diff --git a/src/plugins/qmlprofiler/qmlprofilerstatemanager.h b/src/plugins/qmlprofiler/qmlprofilerstatemanager.h
index 188b0b5be3..c9c576a346 100644
--- a/src/plugins/qmlprofiler/qmlprofilerstatemanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilerstatemanager.h
@@ -49,6 +49,7 @@ public:
AppStopRequested,
AppReadyToStop,
AppStopped,
+ AppDying,
AppKilled
};
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 8c4e1d18a0..37c51acdb0 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -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 :
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h
index fa9ba2e968..cab1c7e520 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.h
+++ b/src/plugins/qmlprofiler/qmlprofilertool.h
@@ -85,6 +85,7 @@ public slots:
void profilerStateChanged();
void clientRecordingChanged();
void serverRecordingChanged();
+ void clientsDisconnected();
void recordingButtonChanged(bool recording);
void setRecording(bool recording);