diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-23 20:01:29 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-24 21:46:44 +0300 |
commit | f18d8fd1fb405d2cefea298e2383e5a2e76fcd7a (patch) | |
tree | 70544d3d816738f1aba04bbf320939536d51be3d /src/network/socket/qlocalsocket_win.cpp | |
parent | 6481733d45805ecbe22a0806923ee2e0894ecc28 (diff) |
QLocalSocket/Win: do not close the device on disconnectFromServer()
It's the user's privilege to do so when they want to finish reading the
QIODevice. Moreover, this is the only difference between close() and
disconnectFromServer().
[ChangeLog][QtNetwork][Important Behavior Changes] The Windows
implementation of QLocalSocket::disconnectFromServer() no longer calls
close(), which is consistent with the behavior on Unix.
Change-Id: Ie9ce20c60259a2b08f5254b719355bd7be9b17cd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/network/socket/qlocalsocket_win.cpp')
-rw-r--r-- | src/network/socket/qlocalsocket_win.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index df319d2c1e..5d0fdfb023 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -337,6 +337,8 @@ void QLocalSocketPrivate::_q_pipeClosed() return; } + serverName.clear(); + fullServerName.clear(); pipeReader->stop(); delete pipeWriter; pipeWriter = nullptr; @@ -403,11 +405,11 @@ void QLocalSocket::disconnectFromServer() { Q_D(QLocalSocket); - if (bytesToWrite() != 0) { + if (bytesToWrite() == 0) { + d->_q_pipeClosed(); + } else if (d->state != QLocalSocket::ClosingState) { d->state = QLocalSocket::ClosingState; emit stateChanged(d->state); - } else { - close(); } } @@ -444,8 +446,8 @@ void QLocalSocketPrivate::_q_bytesWritten(qint64 bytes) QScopedValueRollback<bool> guard(emittedBytesWritten, true); emit q->bytesWritten(bytes); } - if (state == QLocalSocket::ClosingState && pipeWriterBytesToWrite() == 0) - q->close(); + if (state == QLocalSocket::ClosingState) + q->disconnectFromServer(); } qintptr QLocalSocket::socketDescriptor() const |