diff options
24 files changed, 120 insertions, 55 deletions
diff --git a/.qmake.conf b/.qmake.conf index 6fb07da..6cfd011 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,4 +3,4 @@ load(qt_build_config) CONFIG += warning_clean DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.10.1 +MODULE_VERSION = 5.11.0 diff --git a/examples/websockets/echoclient/echoclient.h b/examples/websockets/echoclient/echoclient.h index a0f0d37..a7fd234 100644 --- a/examples/websockets/echoclient/echoclient.h +++ b/examples/websockets/echoclient/echoclient.h @@ -57,7 +57,7 @@ class EchoClient : public QObject { Q_OBJECT public: - explicit EchoClient(const QUrl &url, bool debug = false, QObject *parent = Q_NULLPTR); + explicit EchoClient(const QUrl &url, bool debug = false, QObject *parent = nullptr); Q_SIGNALS: void closed(); diff --git a/examples/websockets/echoserver/echoserver.h b/examples/websockets/echoserver/echoserver.h index 593a8c8..3681917 100644 --- a/examples/websockets/echoserver/echoserver.h +++ b/examples/websockets/echoserver/echoserver.h @@ -61,7 +61,7 @@ class EchoServer : public QObject { Q_OBJECT public: - explicit EchoServer(quint16 port, bool debug = false, QObject *parent = Q_NULLPTR); + explicit EchoServer(quint16 port, bool debug = false, QObject *parent = nullptr); ~EchoServer(); Q_SIGNALS: diff --git a/examples/websockets/sslechoclient/sslechoclient.cpp b/examples/websockets/sslechoclient/sslechoclient.cpp index 3de2fec..6427f88 100644 --- a/examples/websockets/sslechoclient/sslechoclient.cpp +++ b/examples/websockets/sslechoclient/sslechoclient.cpp @@ -59,8 +59,7 @@ SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) : QObject(parent) { connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected); - typedef void (QWebSocket:: *sslErrorsSignal)(const QList<QSslError> &); - connect(&m_webSocket, static_cast<sslErrorsSignal>(&QWebSocket::sslErrors), + connect(&m_webSocket, QOverload<const QList<QSslError>&>::of(&QWebSocket::sslErrors), this, &SslEchoClient::onSslErrors); m_webSocket.open(QUrl(url)); } diff --git a/examples/websockets/sslechoclient/sslechoclient.h b/examples/websockets/sslechoclient/sslechoclient.h index 5b87557..6634a44 100644 --- a/examples/websockets/sslechoclient/sslechoclient.h +++ b/examples/websockets/sslechoclient/sslechoclient.h @@ -63,7 +63,7 @@ class SslEchoClient : public QObject { Q_OBJECT public: - explicit SslEchoClient(const QUrl &url, QObject *parent = Q_NULLPTR); + explicit SslEchoClient(const QUrl &url, QObject *parent = nullptr); private Q_SLOTS: void onConnected(); diff --git a/examples/websockets/sslechoserver/sslechoserver.cpp b/examples/websockets/sslechoserver/sslechoserver.cpp index ae5d9ad..00bc6c1 100644 --- a/examples/websockets/sslechoserver/sslechoserver.cpp +++ b/examples/websockets/sslechoserver/sslechoserver.cpp @@ -60,7 +60,7 @@ QT_USE_NAMESPACE //! [constructor] SslEchoServer::SslEchoServer(quint16 port, QObject *parent) : QObject(parent), - m_pWebSocketServer(Q_NULLPTR) + m_pWebSocketServer(nullptr) { m_pWebSocketServer = new QWebSocketServer(QStringLiteral("SSL Echo Server"), QWebSocketServer::SecureMode, diff --git a/examples/websockets/sslechoserver/sslechoserver.h b/examples/websockets/sslechoserver/sslechoserver.h index 109a78b..8064476 100644 --- a/examples/websockets/sslechoserver/sslechoserver.h +++ b/examples/websockets/sslechoserver/sslechoserver.h @@ -62,7 +62,7 @@ class SslEchoServer : public QObject { Q_OBJECT public: - explicit SslEchoServer(quint16 port, QObject *parent = Q_NULLPTR); + explicit SslEchoServer(quint16 port, QObject *parent = nullptr); virtual ~SslEchoServer(); private Q_SLOTS: diff --git a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp index a0f7c78..416269c 100644 --- a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp +++ b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp @@ -130,7 +130,7 @@ QUrl QQmlWebSocketServer::url() const QUrl url; url.setPort(m_port); url.setHost(m_host); - url.setScheme("ws"); + url.setScheme(QStringLiteral("ws")); return url; } diff --git a/src/websockets/qmaskgenerator.h b/src/websockets/qmaskgenerator.h index 55cd237..5cd8144 100644 --- a/src/websockets/qmaskgenerator.h +++ b/src/websockets/qmaskgenerator.h @@ -50,7 +50,7 @@ class Q_WEBSOCKETS_EXPORT QMaskGenerator : public QObject Q_DISABLE_COPY(QMaskGenerator) public: - explicit QMaskGenerator(QObject *parent = Q_NULLPTR); + explicit QMaskGenerator(QObject *parent = nullptr); virtual ~QMaskGenerator(); virtual bool seed() = 0; diff --git a/src/websockets/qsslserver.cpp b/src/websockets/qsslserver.cpp index 5df59f7..586e520 100644 --- a/src/websockets/qsslserver.cpp +++ b/src/websockets/qsslserver.cpp @@ -115,11 +115,12 @@ void QSslServer::incomingConnection(qintptr socket) if (Q_LIKELY(pSslSocket->setSocketDescriptor(socket))) { connect(pSslSocket, &QSslSocket::peerVerifyError, this, &QSslServer::peerVerifyError); - typedef void (QSslSocket::* sslErrorsSignal)(const QList<QSslError> &); - connect(pSslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), + connect(pSslSocket, QOverload<const QList<QSslError>&>::of(&QSslSocket::sslErrors), this, &QSslServer::sslErrors); - connect(pSslSocket, &QSslSocket::encrypted, this, &QSslServer::newEncryptedConnection); - connect(pSslSocket, &QSslSocket::preSharedKeyAuthenticationRequired, this, &QSslServer::preSharedKeyAuthenticationRequired); + connect(pSslSocket, &QSslSocket::encrypted, + this, &QSslServer::newEncryptedConnection); + connect(pSslSocket, &QSslSocket::preSharedKeyAuthenticationRequired, + this, &QSslServer::preSharedKeyAuthenticationRequired); addPendingConnection(pSslSocket); diff --git a/src/websockets/qsslserver_p.h b/src/websockets/qsslserver_p.h index d5e581a..4cd0eac 100644 --- a/src/websockets/qsslserver_p.h +++ b/src/websockets/qsslserver_p.h @@ -65,7 +65,7 @@ class QSslServer : public QTcpServer Q_DISABLE_COPY(QSslServer) public: - explicit QSslServer(QObject *parent = Q_NULLPTR); + explicit QSslServer(QObject *parent = nullptr); virtual ~QSslServer(); void setSslConfiguration(const QSslConfiguration &sslConfiguration); diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index de5ac22..1b0fc35 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -684,7 +684,7 @@ void QWebSocket::setProxy(const QNetworkProxy &networkProxy) /*! Sets the generator to use for creating masks to \a maskGenerator. - The default QWebSocket generator can be reset by supplying a \e Q_NULLPTR. + The default QWebSocket generator can be reset by supplying a \e nullptr. The mask generator can be changed at any time, even while the connection is open. */ void QWebSocket::setMaskGenerator(const QMaskGenerator *maskGenerator) diff --git a/src/websockets/qwebsocket.h b/src/websockets/qwebsocket.h index cbe53ca..a80c47a 100644 --- a/src/websockets/qwebsocket.h +++ b/src/websockets/qwebsocket.h @@ -68,7 +68,7 @@ class Q_WEBSOCKETS_EXPORT QWebSocket : public QObject public: explicit QWebSocket(const QString &origin = QString(), QWebSocketProtocol::Version version = QWebSocketProtocol::VersionLatest, - QObject *parent = Q_NULLPTR); + QObject *parent = nullptr); virtual ~QWebSocket(); void abort(); @@ -147,7 +147,7 @@ Q_SIGNALS: private: QWebSocket(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, - QObject *parent = Q_NULLPTR); + QObject *parent = nullptr); }; QT_END_NAMESPACE diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 1d23c84..9b29114 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -80,7 +80,7 @@ QWebSocketConfiguration::QWebSocketConfiguration() : #ifndef QT_NO_NETWORKPROXY m_proxy(QNetworkProxy::DefaultProxy), #endif - m_pSocket(Q_NULLPTR) + m_pSocket(nullptr) { } @@ -91,7 +91,7 @@ QWebSocketPrivate::QWebSocketPrivate(const QString &origin, QWebSocketProtocol:: QWebSocket *pWebSocket) : QObjectPrivate(), q_ptr(pWebSocket), - m_pSocket(Q_NULLPTR), + m_pSocket(nullptr), m_errorString(), m_version(version), m_resourceName(), @@ -376,7 +376,7 @@ void QWebSocketPrivate::open(const QNetworkRequest &request, bool mask) if (m_pSocket) { releaseConnections(m_pSocket); m_pSocket->deleteLater(); - m_pSocket = Q_NULLPTR; + m_pSocket = nullptr; } //if (m_url != url) if (Q_LIKELY(!m_pSocket)) { @@ -563,11 +563,9 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket) if (Q_LIKELY(pTcpSocket)) { //pass through signals - typedef void (QAbstractSocket:: *ASErrorSignal)(QAbstractSocket::SocketError); - typedef void (QWebSocket:: *WSErrorSignal)(QAbstractSocket::SocketError); QObject::connect(pTcpSocket, - static_cast<ASErrorSignal>(&QAbstractSocket::error), - q, static_cast<WSErrorSignal>(&QWebSocket::error)); + QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), + q, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error)); #ifndef QT_NO_NETWORKPROXY QObject::connect(pTcpSocket, &QAbstractSocket::proxyAuthenticationRequired, q, &QWebSocket::proxyAuthenticationRequired); @@ -595,12 +593,11 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket) &QWebSocket::preSharedKeyAuthenticationRequired); QObject::connect(sslSocket, &QSslSocket::encryptedBytesWritten, q, &QWebSocket::bytesWritten); - typedef void (QSslSocket:: *sslErrorSignalType)(const QList<QSslError> &); QObjectPrivate::connect(sslSocket, - static_cast<sslErrorSignalType>(&QSslSocket::sslErrors), + QOverload<const QList<QSslError>&>::of(&QSslSocket::sslErrors), this, &QWebSocketPrivate::_q_updateSslConfiguration); QObject::connect(sslSocket, - static_cast<sslErrorSignalType>(&QSslSocket::sslErrors), + QOverload<const QList<QSslError>&>::of(&QSslSocket::sslErrors), q, &QWebSocket::sslErrors); QObjectPrivate::connect(sslSocket, &QSslSocket::encrypted, this, &QWebSocketPrivate::_q_updateSslConfiguration); @@ -967,17 +964,32 @@ void QWebSocketPrivate::processHandshake(QTcpSocket *pSocket) } m_handshakeState = ReadingHeaderState; Q_FALLTHROUGH(); - case ReadingHeaderState: + case ReadingHeaderState: { + // TODO: this should really use the existing code from QHttpNetworkReplyPrivate::parseHeader + auto lastHeader = m_headers.end(); while (pSocket->canReadLine()) { QString headerLine = readLine(pSocket); - const QStringList headerField = headerLine.split(QStringLiteral(": "), - QString::SkipEmptyParts); - if (headerField.size() == 2) { - m_headers.insertMulti(headerField[0].toLower(), headerField[1]); - } - if (headerField.isEmpty()) { + + if (headerLine.isEmpty()) { + // end of headers m_handshakeState = ParsingHeaderState; break; + } else if (headerLine.startsWith(QLatin1Char(' ')) || headerLine.startsWith(QLatin1Char('\t'))) { + // continuation line -- add this to the last header field + if (Q_UNLIKELY(lastHeader == m_headers.end())) { + errorDescription = QWebSocket::tr("Malformed header in response: %1.").arg(headerLine); + break; + } + lastHeader.value().append(QLatin1Char(' ')); + lastHeader.value().append(headerLine.trimmed()); + } else { + int colonPos = headerLine.indexOf(QLatin1Char(':')); + if (Q_UNLIKELY(colonPos <= 0)) { + errorDescription = QWebSocket::tr("Malformed header in response: %1.").arg(headerLine); + break; + } + lastHeader = m_headers.insertMulti(headerLine.left(colonPos).trimmed().toLower(), + headerLine.mid(colonPos + 1).trimmed()); } } @@ -989,6 +1001,7 @@ void QWebSocketPrivate::processHandshake(QTcpSocket *pSocket) return; } Q_FALLTHROUGH(); + } case ParsingHeaderState: { const QString acceptKey = m_headers.value(QStringLiteral("sec-websocket-accept"), QString()); const QString upgrade = m_headers.value(QStringLiteral("upgrade"), QString()); @@ -1140,7 +1153,7 @@ void QWebSocketPrivate::socketDestroyed(QObject *socket) { Q_ASSERT(m_pSocket); if (m_pSocket == socket) - m_pSocket = Q_NULLPTR; + m_pSocket = nullptr; } /*! diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index 4d33788..fd46e0a 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -199,7 +199,7 @@ private: upgradeFrom(QTcpSocket *tcpSocket, const QWebSocketHandshakeRequest &request, const QWebSocketHandshakeResponse &response, - QObject *parent = Q_NULLPTR); + QObject *parent = nullptr); quint32 generateMaskingKey() const; QByteArray generateKey() const; diff --git a/src/websockets/qwebsocketdataprocessor.cpp b/src/websockets/qwebsocketdataprocessor.cpp index d9fc550..8070698 100644 --- a/src/websockets/qwebsocketdataprocessor.cpp +++ b/src/websockets/qwebsocketdataprocessor.cpp @@ -83,7 +83,7 @@ QWebSocketDataProcessor::QWebSocketDataProcessor(QObject *parent) : m_binaryMessage(), m_textMessage(), m_payloadLength(0), - m_pConverterState(Q_NULLPTR), + m_pConverterState(nullptr), m_pTextCodec(QTextCodec::codecForName("UTF-8")) { clear(); @@ -97,7 +97,7 @@ QWebSocketDataProcessor::~QWebSocketDataProcessor() clear(); if (m_pConverterState) { delete m_pConverterState; - m_pConverterState = Q_NULLPTR; + m_pConverterState = nullptr; } } @@ -219,7 +219,7 @@ void QWebSocketDataProcessor::clear() if (m_pConverterState) { if ((m_pConverterState->remainingChars != 0) || (m_pConverterState->invalidChars != 0)) { delete m_pConverterState; - m_pConverterState = Q_NULLPTR; + m_pConverterState = nullptr; } } if (!m_pConverterState) diff --git a/src/websockets/qwebsocketdataprocessor_p.h b/src/websockets/qwebsocketdataprocessor_p.h index 0bf0b8f..79881f8 100644 --- a/src/websockets/qwebsocketdataprocessor_p.h +++ b/src/websockets/qwebsocketdataprocessor_p.h @@ -69,7 +69,7 @@ class Q_AUTOTEST_EXPORT QWebSocketDataProcessor : public QObject Q_DISABLE_COPY(QWebSocketDataProcessor) public: - explicit QWebSocketDataProcessor(QObject *parent = Q_NULLPTR); + explicit QWebSocketDataProcessor(QObject *parent = nullptr); virtual ~QWebSocketDataProcessor(); static quint64 maxMessageSize(); diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp index e6a626c..bfc8a3d 100644 --- a/src/websockets/qwebsockethandshakerequest.cpp +++ b/src/websockets/qwebsockethandshakerequest.cpp @@ -251,14 +251,26 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream, int maxH return; } m_headers.clear(); + // TODO: this should really use the existing code from QHttpNetworkReplyPrivate::parseHeader + auto lastHeader = m_headers.end(); while (!headerLine.isEmpty()) { - const QStringList headerField = headerLine.split(QStringLiteral(": "), - QString::SkipEmptyParts); - if (Q_UNLIKELY(headerField.length() < 2)) { - clear(); - return; + if (headerLine.startsWith(QLatin1Char(' ')) || headerLine.startsWith(QLatin1Char('\t'))) { + // continuation line -- add this to the last header field + if (Q_UNLIKELY(lastHeader == m_headers.end())) { + clear(); + return; + } + lastHeader.value().append(QLatin1Char(' ')); + lastHeader.value().append(headerLine.trimmed()); + } else { + int colonPos = headerLine.indexOf(QLatin1Char(':')); + if (Q_UNLIKELY(colonPos <= 0)) { + clear(); + return; + } + lastHeader = m_headers.insertMulti(headerLine.left(colonPos).trimmed().toLower(), + headerLine.mid(colonPos + 1).trimmed()); } - m_headers.insertMulti(headerField.at(0).toLower(), headerField.at(1)); if (m_headers.size() > maxHeaders) { clear(); return; diff --git a/src/websockets/qwebsocketserver.cpp b/src/websockets/qwebsocketserver.cpp index e4cfe12..be66946 100644 --- a/src/websockets/qwebsocketserver.cpp +++ b/src/websockets/qwebsocketserver.cpp @@ -354,7 +354,7 @@ int QWebSocketServer::maxPendingConnections() const QWebSocketServer does not take ownership of the returned QWebSocket object. It is up to the caller to delete the object explicitly when it will no longer be used, otherwise a memory leak will occur. - Q_NULLPTR is returned if this function is called when there are no pending connections. + nullptr is returned if this function is called when there are no pending connections. Note: The returned QWebSocket object cannot be used from another thread. diff --git a/src/websockets/qwebsocketserver.h b/src/websockets/qwebsocketserver.h index 9dc286b..decd7c3 100644 --- a/src/websockets/qwebsocketserver.h +++ b/src/websockets/qwebsocketserver.h @@ -75,7 +75,7 @@ public: Q_ENUM(SslMode) explicit QWebSocketServer(const QString &serverName, SslMode secureMode, - QObject *parent = Q_NULLPTR); + QObject *parent = nullptr); virtual ~QWebSocketServer(); bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0); diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 55e9484..59b50e7 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -69,7 +69,7 @@ QWebSocketServerPrivate::QWebSocketServerPrivate(const QString &serverName, QWebSocketServer * const pWebSocketServer) : QObjectPrivate(), q_ptr(pWebSocketServer), - m_pTcpServer(Q_NULLPTR), + m_pTcpServer(nullptr), m_serverName(serverName), m_secureMode(secureMode), m_pendingConnections(), @@ -211,7 +211,7 @@ void QWebSocketServerPrivate::setErrorFromSocketError(QAbstractSocket::SocketErr */ QWebSocket *QWebSocketServerPrivate::nextPendingConnection() { - QWebSocket *pWebSocket = Q_NULLPTR; + QWebSocket *pWebSocket = nullptr; if (Q_LIKELY(!m_pendingConnections.isEmpty())) pWebSocket = m_pendingConnections.dequeue(); return pWebSocket; diff --git a/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp b/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp index 4a9603f..230b052 100644 --- a/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp +++ b/tests/auto/websockets/handshakerequest/tst_handshakerequest.cpp @@ -63,6 +63,7 @@ private Q_SLOTS: void tst_multipleValuesInConnectionHeader(); void tst_multipleVersions(); + void tst_parsingWhitespaceInHeaders(); void tst_qtbug_39355(); void tst_qtbug_48123_data(); @@ -194,6 +195,17 @@ void tst_HandshakeRequest::tst_invalidStream_data() QStringLiteral("Sec-WebSocket-Key: AVDFBDDFF\r\n") + QStringLiteral("Upgrade: websocket,ftp\r\n") + QStringLiteral("Connection: Upgrade\r\n\r\n"); + QTest::newRow("Invalid header - starts with continuation") + << QStringLiteral("GET . HTTP/1.1\r\n Host: foo\r\nSec-WebSocket-Version: 13\r\n") + + QStringLiteral("Sec-WebSocket-Key: AVDFBDDFF\r\n") + + QStringLiteral("Upgrade: websocket\r\n") + + QStringLiteral("Connection: Upgrade\r\n\r\n"); + QTest::newRow("Invalid header - no colon") + << QStringLiteral("GET . HTTP/1.1\r\nHost: foo\r\nSec-WebSocket-Version: 13\r\n") + + QStringLiteral("Sec-WebSocket-Key: AVDFBDDFF\r\n") + + QStringLiteral("Upgrade: websocket\r\n") + + QStringLiteral("X-Custom foo\r\n") + + QStringLiteral("Connection: Upgrade\r\n\r\n"); } void tst_HandshakeRequest::tst_invalidStream() @@ -259,6 +271,34 @@ void tst_HandshakeRequest::tst_multipleValuesInConnectionHeader() QCOMPARE(request.versions().at(0), QWebSocketProtocol::Version13); } +/* + * This is a regression test + * Checks for RFC compliant header parsing + */ +void tst_HandshakeRequest::tst_parsingWhitespaceInHeaders() +{ + //doing extensive QStringLiteral concatenations here, because + //MSVC 2010 complains when using concatenation literal strings about + //concatenation of wide and narrow strings (error C2308) + QString header = QStringLiteral("GET /test HTTP/1.1\r\nHost: ") + + QStringLiteral("foo.com\r\nSec-WebSocket-Version:13\r\n") + + QStringLiteral("Sec-WebSocket-Key: AVD \r\n\tFBDDFF \r\n") + + QStringLiteral("Upgrade:websocket \r\n") + + QStringLiteral("Connection: Upgrade,keepalive\r\n\r\n"); + QByteArray data; + QTextStream textStream(&data); + QWebSocketHandshakeRequest request(80, false); + + textStream << header; + textStream.seek(0); + request.readHandshake(textStream, MAX_HEADERLINE_LENGTH, MAX_HEADERS); + + QVERIFY(request.isValid()); + QCOMPARE(request.key(), QStringLiteral("AVD FBDDFF")); + QCOMPARE(request.versions().length(), 1); + QCOMPARE(request.versions().at(0), QWebSocketProtocol::Version13); +} + void tst_HandshakeRequest::tst_multipleVersions() { QString header = QStringLiteral("GET /test HTTP/1.1\r\nHost: foo.com\r\n") + diff --git a/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp b/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp index dfa0ce5..ac54270 100644 --- a/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp +++ b/tests/auto/websockets/qwebsocket/tst_qwebsocket.cpp @@ -39,7 +39,7 @@ class EchoServer : public QObject { Q_OBJECT public: - explicit EchoServer(QObject *parent = Q_NULLPTR); + explicit EchoServer(QObject *parent = nullptr); ~EchoServer(); QHostAddress hostAddress() const { return m_pWebSocketServer->serverAddress(); } @@ -659,7 +659,7 @@ void tst_QWebSocket::tst_moveToThread() EchoServer echoServer; - QThread* thread = new QThread; + QThread* thread = new QThread(this); thread->start(); WebSocket* socket = new WebSocket; @@ -696,7 +696,7 @@ void tst_QWebSocket::tst_moveToThread() socket->deleteLater(); thread->quit(); - thread->deleteLater(); + thread->wait(); } void tst_QWebSocket::tst_moveToThreadNoWarning() diff --git a/tests/manual/compliance/tst_compliance.cpp b/tests/manual/compliance/tst_compliance.cpp index 64bb335..478ca33 100644 --- a/tests/manual/compliance/tst_compliance.cpp +++ b/tests/manual/compliance/tst_compliance.cpp @@ -109,7 +109,7 @@ void tst_ComplianceTest::runTestCase(int nbr, int total) spy.wait(60000); pWebSocket->close(); delete pWebSocket; - pWebSocket = Q_NULLPTR; + pWebSocket = nullptr; runTestCase(nbr + 1, total); } |