Adapt isValid to only return true when socket is in connected state
authorKurt Pattyn <pattyn.kurt@gmail.com>
Sun, 26 Jan 2014 17:04:05 +0000 (18:04 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 1 Feb 2014 19:12:57 +0000 (20:12 +0100)
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 <pattyn.kurt@gmail.com>
src/websockets/qwebsocket.cpp
src/websockets/qwebsocket_p.cpp

index 39998cc..b500853 100644 (file)
@@ -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
 {
index f0eae30..91588c0 100644 (file)
@@ -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