From 84b4b52aedb09cf2924e5587b011be665541795f Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Fri, 11 May 2012 17:19:15 +0200 Subject: [PATCH] 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 --- src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp | 5 +++++ src/plugins/qmlprofiler/qmlprofilerclientmanager.h | 1 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp index 7bf5a117272..91fc4043c58 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp @@ -236,6 +236,11 @@ void QmlProfilerClientManager::connectToClient() } } +bool QmlProfilerClientManager::isConnected() const +{ + return d->connection && d->connection->isConnected(); +} + void QmlProfilerClientManager::disconnectClient() { // this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h index 87f62c944c1..a8f6c5ceb6c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.h @@ -56,6 +56,7 @@ public: void clearBufferedData(); void discardPendingData(); + bool isConnected() const; signals: void connectionFailed(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 8cef7cf673c..287ffff211f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -719,6 +719,12 @@ void QmlProfilerTool::handleHelpRequest(const QString &link) void QmlProfilerTool::profilerStateChanged() { 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 : { showNonmodalWarning(tr("Application finished before loading profiled data.\n Please use the stop button instead.")); break;