QAbstractSocket: print error message before emitting the signal

The socket might get closed by some slot connected to its error() signal.
This could lead to 'errorString' being cleared, which would hide the actual
error code from the debug output. Changing the order of calls ensures we
always get the correct message.

Change-Id: If7c01196dbeb3cb0c97235cd02a3baf63fc190da
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Alex Trotsenko 2016-11-01 20:13:42 +02:00
parent 7bf81286bd
commit b3d871554c

View File

@ -1274,11 +1274,11 @@ bool QAbstractSocketPrivate::readFromSocket()
}
if (!socketEngine->isValid()) {
setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::readFromSocket() read failed: %s",
q->errorString().toLatin1().constData());
socketEngine->errorString().toLatin1().constData());
#endif
setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
resetSocketLayer();
return false;
}