From d6d679caa4ebaf6d78e134976e48f7c4aeadf02f Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Sun, 26 Jan 2014 18:04:05 +0100 Subject: [PATCH] Adapt isValid to only return true when socket is in connected state Changed isValid() to only return true when the socket is also in connected state. Also updated the documentation. Change-Id: Id80dbc1f28c82bef19984c5ed7b34a7d474ee011 Reviewed-by: Kurt Pattyn --- src/websockets/qwebsocket.cpp | 3 ++- src/websockets/qwebsocket_p.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index 39998cc..b500853 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -678,7 +678,8 @@ void QWebSocket::setReadBufferSize(qint64 size) } /*! - Returns true if the QWebSocket is valid. + Returns \c true if the socket is ready for reading and writing; otherwise + returns \c false. */ bool QWebSocket::isValid() const { diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index f0eae30..91588c0 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -1225,7 +1225,8 @@ void QWebSocketPrivate::setReadBufferSize(qint64 size) */ bool QWebSocketPrivate::isValid() const { - return (m_pSocket && m_pSocket->isValid()); + return (m_pSocket && m_pSocket->isValid() && + (m_socketState == QAbstractSocket::ConnectedState)); } QT_END_NAMESPACE -- 2.7.4