From 4e9eb911ffc70959d81de01fe9fe4a704cafe3eb Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 1 Apr 2011 18:35:28 +0200 Subject: fix QLocalSocket::isValid() on Windows This function always returned false, even if the socket was connected. Task-number: QTBUG-18204 Reviewed-by: Martin Petersson --- src/network/socket/qlocalsocket_win.cpp | 5 +---- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 468bf8d..bd566a5 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -574,10 +574,7 @@ bool QLocalSocket::waitForDisconnected(int msecs) bool QLocalSocket::isValid() const { Q_D(const QLocalSocket); - if (d->handle == INVALID_HANDLE_VALUE) - return false; - - return PeekNamedPipe(d->handle, NULL, 0, NULL, NULL, NULL); + return d->handle != INVALID_HANDLE_VALUE; } bool QLocalSocket::waitForReadyRead(int msecs) diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index a6d4427..77a5574 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -391,6 +391,8 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(socket->fullServerName().contains(name)); sockets.append(socket); if (canListen) { + QVERIFY(socket->waitForConnected()); + QVERIFY(socket->isValid()); QCOMPARE(socket->errorString(), QString("Unknown error")); QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::ConnectedState); -- cgit v0.12