QmlProfiler: manage premature disconnection when app killed

The profiler tool was assuming that the socket would get
disconnected after the application was stopped by the user.
Sometimes it is not the case.  This patch manages the
oposite situation gracefully.

Change-Id: I4ae439bf2ce6caece37e97f735e980d18c446df0
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2012-05-11 17:19:15 +02:00
parent bbbc08a6ea
commit 84b4b52aed
3 changed files with 12 additions and 0 deletions

View File

@@ -236,6 +236,11 @@ void QmlProfilerClientManager::connectToClient()
} }
} }
bool QmlProfilerClientManager::isConnected() const
{
return d->connection && d->connection->isConnected();
}
void QmlProfilerClientManager::disconnectClient() void QmlProfilerClientManager::disconnectClient()
{ {
// this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow // this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow

View File

@@ -56,6 +56,7 @@ public:
void clearBufferedData(); void clearBufferedData();
void discardPendingData(); void discardPendingData();
bool isConnected() const;
signals: signals:
void connectionFailed(); void connectionFailed();

View File

@@ -719,6 +719,12 @@ void QmlProfilerTool::handleHelpRequest(const QString &link)
void QmlProfilerTool::profilerStateChanged() void QmlProfilerTool::profilerStateChanged()
{ {
switch (d->m_profilerState->currentState()) { switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppDying : {
// If already disconnected when dying, check again that all data was read
if (!d->m_profilerConnections->isConnected())
QTimer::singleShot(0, this, SLOT(clientsDisconnected()));
break;
}
case QmlProfilerStateManager::AppKilled : { case QmlProfilerStateManager::AppKilled : {
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;