aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2014-05-05 17:18:11 +0200
committerUlf Hermann <[email protected]>2014-05-08 15:23:56 +0200
commita7012c5a879b24f2bd53fc1d2425a211b61136da (patch)
tree2b07c0b6354de3155cc73ddc53db5c792ad98f30 /src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
parentb63d9c6df0e6638c2b40a7351026aed6aab2b953 (diff)
QmlDebugClient: hide all the socket details from clients
Like this no one will get the idea that the socket state represents the connection state and we can safely replace the underlying implementation with something not derived from QAbstractSocket. All the logging is retained but the connection creates the messages now. Change-Id: If84ff42f1fa9785254fbd49c75be867b9f663c83 Reviewed-by: Kai Koehne <[email protected]>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp71
1 files changed, 25 insertions, 46 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
index 906573dde1a..b41d4358e07 100644
--- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp
@@ -147,8 +147,10 @@ void QmlProfilerClientManager::connectClient(quint16 port)
delete d->connection;
d->connection = new QmlDebugConnection;
enableServices();
- connect(d->connection, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)),
- this, SLOT(connectionStateChanged()));
+ connect(d->connection, SIGNAL(stateMessage(QString)), this, SLOT(logState(QString)));
+ connect(d->connection, SIGNAL(errorMessage(QString)), this, SLOT(logState(QString)));
+ connect(d->connection, SIGNAL(opened()), this, SLOT(qmlDebugConnectionOpened()));
+ connect(d->connection, SIGNAL(closed()), this, SLOT(qmlDebugConnectionClosed()));
d->connectionTimer.start();
d->tcpPort = port;
}
@@ -235,7 +237,7 @@ void QmlProfilerClientManager::disconnectClientSignals()
void QmlProfilerClientManager::connectToClient()
{
- if (!d->connection || d->connection->socketState() != QAbstractSocket::UnconnectedState)
+ if (!d->connection || d->connection->isOpen())
return;
d->connection->connectToHost(d->tcpHost, d->tcpPort);
@@ -287,45 +289,25 @@ void QmlProfilerClientManager::tryToConnect()
}
}
-void QmlProfilerClientManager::connectionStateChanged()
+void QmlProfilerClientManager::qmlDebugConnectionOpened()
{
- if (!d->connection)
- return;
- switch (d->connection->socketState()) {
- case QAbstractSocket::UnconnectedState:
- {
- if (QmlProfilerPlugin::debugOutput)
- qWarning("QML Profiler: disconnected");
- disconnectClient();
- emit connectionClosed();
- break;
- }
- case QAbstractSocket::HostLookupState:
- break;
- case QAbstractSocket::ConnectingState: {
- if (QmlProfilerPlugin::debugOutput)
- qWarning("QML Profiler: Connecting to debug server ...");
- QmlProfilerTool::logState(tr("QML Profiler: Connecting to %1:%2 ...")
- .arg(d->tcpHost, QString::number(d->tcpPort)));
- break;
- }
- case QAbstractSocket::ConnectedState:
- {
- if (QmlProfilerPlugin::debugOutput)
- qWarning("QML Profiler: connected and running");
- // notify the client recording status
- clientRecordingChanged();
- QmlProfilerTool::logState(tr("QML Profiler: connected and running"));
- break;
- }
- case QAbstractSocket::ClosingState:
- if (QmlProfilerPlugin::debugOutput)
- qWarning("QML Profiler: closing ...");
- break;
- case QAbstractSocket::BoundState:
- case QAbstractSocket::ListeningState:
- break;
- }
+ logState(tr("Debug connection opened"));
+ clientRecordingChanged();
+}
+
+void QmlProfilerClientManager::qmlDebugConnectionClosed()
+{
+ logState(tr("Debug connection closed"));
+ disconnectClient();
+ emit connectionClosed();
+}
+
+void QmlProfilerClientManager::logState(const QString &msg)
+{
+ QString state = QLatin1String("QML Profiler: ") + msg;
+ if (QmlProfilerPlugin::debugOutput)
+ qWarning() << state;
+ QmlProfilerTool::logState(state);
}
void QmlProfilerClientManager::retryMessageBoxFinished(int result)
@@ -341,11 +323,8 @@ void QmlProfilerClientManager::retryMessageBoxFinished(int result)
// fall through
}
default: {
- if (d->connection)
- QmlProfilerTool::logState(QLatin1String("QML Profiler: Failed to connect! ") + d->connection->errorString());
- else
- QmlProfilerTool::logState(QLatin1String("QML Profiler: Failed to connect!"));
-
+ // The actual error message has already been logged.
+ logState(tr("Failed to connect!"));
emit connectionFailed();
break;
}