diff options
-rw-r--r-- | src/network/socket/qlocalsocket_p.h | 6 | ||||
-rw-r--r-- | src/network/socket/qlocalsocket_win.cpp | 17 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index 081697b..0f1c23c 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -128,10 +128,8 @@ public: void _q_stateChanged(QAbstractSocket::SocketState newState); void _q_error(QAbstractSocket::SocketError newError); #elif defined(Q_OS_WIN) - ~QLocalSocketPrivate() { - CloseHandle(overlapped.hEvent); - } - + ~QLocalSocketPrivate(); + void destroyPipeHandles(); void setErrorString(const QString &function); void _q_notified(); void _q_canWrite(); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 1f94df6..7a1e84b 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -110,6 +110,20 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), { } +QLocalSocketPrivate::~QLocalSocketPrivate() +{ + destroyPipeHandles(); + CloseHandle(overlapped.hEvent); +} + +void QLocalSocketPrivate::destroyPipeHandles() +{ + if (handle != INVALID_HANDLE_VALUE) { + DisconnectNamedPipe(handle); + CloseHandle(handle); + } +} + void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) { Q_D(QLocalSocket); @@ -388,8 +402,7 @@ void QLocalSocket::close() d->readSequenceStarted = false; d->pendingReadyRead = false; d->pipeClosed = false; - DisconnectNamedPipe(d->handle); - CloseHandle(d->handle); + d->destroyPipeHandles(); d->handle = INVALID_HANDLE_VALUE; ResetEvent(d->overlapped.hEvent); d->state = UnconnectedState; |