From 059bf03f30c0e27830d311ae9a664eb0376fcd1f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 9 Apr 2010 16:13:57 +0200 Subject: fix closing state in QLocalSocket on Windows When closing a QLocalSocket, which has unwritten data, the pipe writer was never deleted. Thus writing after a reconnect didn't work. Task-number: QTBUG-9681 Reviewed-by: ossi --- src/network/socket/qlocalsocket_win.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 3283bf2..5f46ecb 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "qlocalsocket.h" #include "qlocalsocket_p.h" #include @@ -425,6 +424,15 @@ bool QLocalSocket::flush() void QLocalSocket::disconnectFromServer() { Q_D(QLocalSocket); + + // Are we still connected? + if (!isValid()) { + // If we have unwritten data, the pipeWriter is still present. + // It must be destroyed before close() to prevent an infinite loop. + delete d->pipeWriter; + d->pipeWriter = 0; + } + flush(); if (d->pipeWriter && d->pipeWriter->bytesToWrite() != 0) { d->state = QLocalSocket::ClosingState; -- cgit v0.12