QAbstractSocket: clear error code to match the error description

Since 5.10, QIODevice resets the error string on opening. So, we should
set the error code to UnknownSocketError accordingly.

Change-Id: I0dd314788ffc182d6837f9d06b51e41d6de59d7e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Alex Trotsenko 2017-12-02 19:22:00 +02:00
parent b08c195264
commit d02a6b938e
2 changed files with 5 additions and 0 deletions

View File

@ -1694,6 +1694,8 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
}
#endif
// Sync up with error string, which open() shall clear.
d->socketError = UnknownSocketError;
if (openMode & QIODevice::Unbuffered)
d->isBuffered = false;
else if (!d_func()->isBuffered)
@ -1929,6 +1931,8 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
return false;
}
// Sync up with error string, which open() shall clear.
d->socketError = UnknownSocketError;
if (d->threadData->hasEventDispatcher())
d->socketEngine->setReceiver(d);

View File

@ -153,6 +153,7 @@ public:
QAbstractSocket::SocketType socketType;
QAbstractSocket::SocketState state;
// Must be kept in sync with QIODevicePrivate::errorString.
QAbstractSocket::SocketError socketError;
QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol;