From 81eea72d44531107ace4ae4a3c525ff6b9cd23cc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 16 Nov 2015 17:29:17 +0100 Subject: QmlDebug: Simplify error and state signaling There is no point in sending two signals for every state change and error. Also, the signals only reflect events in the socket, not in the logical connection. Change-Id: I617a925c69164aa1a02a7781b9da7dca55daa304 Reviewed-by: Joerg Bornemann --- src/plugins/debugger/qml/qmlengine.cpp | 22 ++++++++++------------ src/plugins/debugger/qml/qmlengine.h | 6 +++--- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src/plugins/debugger') diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index a8ac02e147..9d290e8c2c 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -291,11 +291,9 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin connect(&d->connectionTimer, &QTimer::timeout, this, &QmlEngine::checkConnectionState); - connect(d->connection, &QmlDebugConnection::stateMessage, - this, &QmlEngine::showConnectionStateMessage); - connect(d->connection, &QmlDebugConnection::errorMessage, - this, &QmlEngine::showConnectionErrorMessage); - connect(d->connection, &QmlDebugConnection::error, + connect(d->connection, &QmlDebugConnection::socketStateChanged, + this, &QmlEngine::connectionStateChanged); + connect(d->connection, &QmlDebugConnection::socketError, this, &QmlEngine::connectionErrorOccurred); connect(d->connection, &QmlDebugConnection::connected, &d->connectionTimer, &QTimer::stop); @@ -1213,11 +1211,11 @@ bool QmlEnginePrivate::canEvaluateScript(const QString &script) return interpreter.canEvaluate(); } -void QmlEngine::connectionErrorOccurred(QDebugSupport::Error error) +void QmlEngine::connectionErrorOccurred(QAbstractSocket::SocketError error) { // this is only an error if we are already connected and something goes wrong. if (isConnected()) { - if (error == QDebugSupport::RemoteClosedConnectionError) + if (error == QAbstractSocket::RemoteHostClosedError) showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar); if (!isSlaveEngine()) { // normal flow for slave engine when gdb exits @@ -1230,6 +1228,11 @@ void QmlEngine::connectionErrorOccurred(QDebugSupport::Error error) } } +void QmlEngine::connectionStateChanged(QAbstractSocket::SocketState socketState) +{ + showConnectionStateMessage(QmlDebugConnection::socketStateToString(socketState)); +} + void QmlEngine::clientStateChanged(QmlDebugClient::State state) { QString serviceName; @@ -1260,11 +1263,6 @@ void QmlEngine::showConnectionStateMessage(const QString &message) showMessage(_("QML Debugger: ") + message, LogStatus); } -void QmlEngine::showConnectionErrorMessage(const QString &message) -{ - showMessage(_("QML Debugger: ") + message, LogError); -} - void QmlEngine::logServiceStateChange(const QString &service, float version, QmlDebugClient::State newState) { diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index 479dddb746..24942b8feb 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -142,11 +141,12 @@ private: void startApplicationLauncher(); void stopApplicationLauncher(); - void connectionErrorOccurred(QDebugSupport::Error socketError); + void connectionErrorOccurred(QAbstractSocket::SocketError socketError); + void connectionStateChanged(QAbstractSocket::SocketState socketState); + void clientStateChanged(QmlDebug::QmlDebugClient::State state); void checkConnectionState(); void showConnectionStateMessage(const QString &message); - void showConnectionErrorMessage(const QString &message); bool isConnected() const; private: -- cgit v1.2.1