src/network/socket/qlocalsocket_win.cpp
changeset 22 79de32ba3296
parent 18 2f34d5167611
child 33 3e2da88830cd
--- a/src/network/socket/qlocalsocket_win.cpp	Mon May 03 13:17:34 2010 +0300
+++ b/src/network/socket/qlocalsocket_win.cpp	Fri May 14 16:40:13 2010 +0300
@@ -39,7 +39,6 @@
 **
 ****************************************************************************/
 
-#include "qlocalsocket.h"
 #include "qlocalsocket_p.h"
 
 #include <private/qthread_p.h>
@@ -425,6 +424,15 @@
 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;