summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-09-15 17:07:33 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2014-11-03 11:38:47 +0100
commitd6a24fd24597af8cdff5944d32a54acb01b806f3 (patch)
treede32b7b3169d944a08e84183219c6969784ca098
parent4ccbf920d63ae1bf52b8a3bf6c795822172acc24 (diff)
downloadqtwebsockets-d6a24fd24597af8cdff5944d32a54acb01b806f3.tar.gz
Make QWebSocketPrivate::makeConnections() take care of all connections.
Otherwise all code that calls it has to handle the other connections separately, which is error-prone and has actually been forgotten for the case where the QWebSocket is created via upgradeFrom(). Task-number: QTBUG-39551 Change-Id: I4d1e4faa1594b53e7a8dccc9ce13ef2c323b1c61 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
-rw-r--r--src/websockets/qwebsocket_p.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 1932aeb..5b37a27 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -392,12 +392,6 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask)
m_pSocket->setPauseMode(m_pauseMode);
makeConnections(m_pSocket.data());
- QObject::connect(sslSocket, &QSslSocket::encryptedBytesWritten, q,
- &QWebSocket::bytesWritten);
- typedef void (QSslSocket:: *sslErrorSignalType)(const QList<QSslError> &);
- QObject::connect(sslSocket,
- static_cast<sslErrorSignalType>(&QSslSocket::sslErrors),
- q, &QWebSocket::sslErrors);
setSocketState(QAbstractSocket::ConnectingState);
sslSocket->setSslConfiguration(m_configuration.m_sslConfiguration);
@@ -426,8 +420,6 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask)
m_pSocket->setPauseMode(m_pauseMode);
makeConnections(m_pSocket.data());
- QObject::connect(m_pSocket.data(), &QAbstractSocket::bytesWritten, q,
- &QWebSocket::bytesWritten);
setSocketState(QAbstractSocket::ConnectingState);
#ifndef QT_NO_NETWORKPROXY
m_pSocket->setProxy(m_configuration.m_proxy);
@@ -545,7 +537,7 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket)
#ifndef QT_NO_NETWORKPROXY
QObject::connect(pTcpSocket, &QAbstractSocket::proxyAuthenticationRequired, q,
&QWebSocket::proxyAuthenticationRequired);
-#endif
+#endif // QT_NO_NETWORKPROXY
QObject::connect(pTcpSocket, &QAbstractSocket::readChannelFinished, q,
&QWebSocket::readChannelFinished);
QObject::connect(pTcpSocket, &QAbstractSocket::aboutToClose, q, &QWebSocket::aboutToClose);
@@ -557,6 +549,21 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket)
//with QTcpSocket there is no problem, but with QSslSocket the processing hangs
QObjectPrivate::connect(pTcpSocket, &QAbstractSocket::readyRead, this,
&QWebSocketPrivate::processData, Qt::QueuedConnection);
+#ifndef QT_NO_SSL
+ const QSslSocket * const sslSocket = qobject_cast<const QSslSocket *>(pTcpSocket);
+ if (sslSocket) {
+ QObject::connect(sslSocket, &QSslSocket::encryptedBytesWritten, q,
+ &QWebSocket::bytesWritten);
+ typedef void (QSslSocket:: *sslErrorSignalType)(const QList<QSslError> &);
+ QObject::connect(sslSocket,
+ static_cast<sslErrorSignalType>(&QSslSocket::sslErrors),
+ q, &QWebSocket::sslErrors);
+ } else
+#endif // QT_NO_SSL
+ {
+ QObject::connect(pTcpSocket, &QAbstractSocket::bytesWritten, q,
+ &QWebSocket::bytesWritten);
+ }
}
QObject::connect(&m_dataProcessor, &QWebSocketDataProcessor::textFrameReceived, q,