forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -70,35 +70,16 @@ public:
|
|||||||
|
|
||||||
static QString socketStateToString(QAbstractSocket::SocketState state)
|
static QString socketStateToString(QAbstractSocket::SocketState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
QString stateString;
|
||||||
case QAbstractSocket::UnconnectedState:
|
QDebug(&stateString) << state;
|
||||||
return QmlDebugConnection::tr("Network connection dropped");
|
return QmlDebugConnection::tr("Socket state changed to %1").arg(stateString);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString socketErrorToString(QAbstractSocket::SocketError error)
|
static QString socketErrorToString(QAbstractSocket::SocketError error)
|
||||||
{
|
{
|
||||||
if (error == QAbstractSocket::RemoteHostClosedError) {
|
QString errorString;
|
||||||
return QmlDebugConnection::tr("Error: Remote host closed the connection");
|
QDebug(&errorString) << error;
|
||||||
} else {
|
return QmlDebugConnection::tr("Error: %1").arg(errorString);
|
||||||
return QmlDebugConnection::tr("Error: Unknown socket error %1").arg(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDebugConnectionPrivate::QmlDebugConnectionPrivate() :
|
QmlDebugConnectionPrivate::QmlDebugConnectionPrivate() :
|
||||||
|
Reference in New Issue
Block a user