Make QAbstractSocket::abort() behavior unambiguous

After calling this function, the user expects that the connection is
terminated, I/O device is closed and the socket is ready for a new
attempt. But, if the socket was disconnected before the call, close()
is not called and I/O device remains opened.

Because QAbstractSocket::close() and QIODevice::close() can handle
reentering, we can call close() unconditionally, which makes
the behavior obvious.

Change-Id: I90a9cbb1a1fe8f866b55ef0bd68d286b34e853f5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Alex Trotsenko 2020-07-31 18:04:53 +03:00
parent 12e4b63d28
commit cced8c9005
1 changed files with 0 additions and 2 deletions

View File

@ -2406,8 +2406,6 @@ void QAbstractSocket::abort()
qDebug("QAbstractSocket::abort()");
#endif
d->setWriteChannelCount(0);
if (d->state == UnconnectedState)
return;
#ifndef QT_NO_SSL
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
socket->abort();