From 48570a754ed28871445a8aadcca041f01ec50e16 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 4 Jan 2017 19:13:29 +0100 Subject: [PATCH] QmlDebug: Use the original names for connection states and errors The way to extract them from Qt is somewhat funny, but this leads to clearer messages in the debugger log and other places. Change-Id: Ib458d5ec796a2e69a6543d405593be8e54016946 Task-number: QTCREATORBUG-17492 Reviewed-by: hjk --- src/libs/qmldebug/qmldebugclient.cpp | 31 ++++++---------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/libs/qmldebug/qmldebugclient.cpp b/src/libs/qmldebug/qmldebugclient.cpp index ab3869b5382..a1ac4ecddf2 100644 --- a/src/libs/qmldebug/qmldebugclient.cpp +++ b/src/libs/qmldebug/qmldebugclient.cpp @@ -70,35 +70,16 @@ public: static QString socketStateToString(QAbstractSocket::SocketState state) { - switch (state) { - case QAbstractSocket::UnconnectedState: - return QmlDebugConnection::tr("Network connection dropped"); - case QAbstractSocket::HostLookupState: - return QmlDebugConnection::tr("Resolving host"); - case QAbstractSocket::ConnectingState: - return QmlDebugConnection::tr("Establishing network connection..."); - case QAbstractSocket::ConnectedState: - return QmlDebugConnection::tr("Network connection established"); - case QAbstractSocket::ClosingState: - return QmlDebugConnection::tr("Network connection closing"); - case QAbstractSocket::BoundState: - return QmlDebugConnection::tr("Socket state changed to BoundState. " - "This should not happen."); - case QAbstractSocket::ListeningState: - return QmlDebugConnection::tr("Socket state changed to ListeningState. " - "This should not happen."); - default: - return QmlDebugConnection::tr("Unknown state %1").arg(state); - } + QString stateString; + QDebug(&stateString) << state; + return QmlDebugConnection::tr("Socket state changed to %1").arg(stateString); } static QString socketErrorToString(QAbstractSocket::SocketError error) { - if (error == QAbstractSocket::RemoteHostClosedError) { - return QmlDebugConnection::tr("Error: Remote host closed the connection"); - } else { - return QmlDebugConnection::tr("Error: Unknown socket error %1").arg(error); - } + QString errorString; + QDebug(&errorString) << error; + return QmlDebugConnection::tr("Error: %1").arg(errorString); } QmlDebugConnectionPrivate::QmlDebugConnectionPrivate() :