From 22c2568af7617ce709aad10540027d25c9d4a09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 16 Aug 2022 13:33:15 +0200 Subject: [PATCH] QSslServer: pass 'this' as a context to connections to socket Then we don't have to do a 'global' disconnect() on the socket object just to disconnect the QSslServer from the socket. Change-Id: Ie3c9680db2717e21a0c548c74374a58d533534fe Reviewed-by: Konrad Kujawa Reviewed-by: Timur Pocheptsov (cherry picked from commit fb4123f36a88f6e890ed2e7f9b462665bfdcd6c0) Reviewed-by: Qt Cherry-pick Bot --- src/network/ssl/qsslserver.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/network/ssl/qsslserver.cpp b/src/network/ssl/qsslserver.cpp index 727d6477845..a26e79e315e 100644 --- a/src/network/ssl/qsslserver.cpp +++ b/src/network/ssl/qsslserver.cpp @@ -241,39 +241,39 @@ void QSslServer::incomingConnection(qintptr socket) pSslSocket->setSslConfiguration(sslConfiguration()); if (Q_LIKELY(pSslSocket->setSocketDescriptor(socket))) { - connect(pSslSocket, &QSslSocket::peerVerifyError, + connect(pSslSocket, &QSslSocket::peerVerifyError, this, [this, pSslSocket](const QSslError &error) { Q_EMIT peerVerifyError(pSslSocket, error); }); - connect(pSslSocket, &QSslSocket::sslErrors, + connect(pSslSocket, &QSslSocket::sslErrors, this, [this, pSslSocket](const QList &errors) { Q_EMIT sslErrors(pSslSocket, errors); }); - connect(pSslSocket, &QAbstractSocket::errorOccurred, + connect(pSslSocket, &QAbstractSocket::errorOccurred, this, [this, pSslSocket](QAbstractSocket::SocketError error) { Q_EMIT errorOccurred(pSslSocket, error); if (!pSslSocket->isEncrypted()) pSslSocket->deleteLater(); }); - connect(pSslSocket, &QSslSocket::encrypted, [this, pSslSocket]() { - pSslSocket->disconnect(); + connect(pSslSocket, &QSslSocket::encrypted, this, [this, pSslSocket]() { + pSslSocket->disconnect(this); addPendingConnection(pSslSocket); }); - connect(pSslSocket, &QSslSocket::preSharedKeyAuthenticationRequired, + connect(pSslSocket, &QSslSocket::preSharedKeyAuthenticationRequired, this, [this, pSslSocket](QSslPreSharedKeyAuthenticator *authenticator) { Q_EMIT preSharedKeyAuthenticationRequired(pSslSocket, authenticator); }); - connect(pSslSocket, &QSslSocket::alertSent, + connect(pSslSocket, &QSslSocket::alertSent, this, [this, pSslSocket](QSsl::AlertLevel level, QSsl::AlertType type, const QString &description) { Q_EMIT alertSent(pSslSocket, level, type, description); }); - connect(pSslSocket, &QSslSocket::alertReceived, + connect(pSslSocket, &QSslSocket::alertReceived, this, [this, pSslSocket](QSsl::AlertLevel level, QSsl::AlertType type, const QString &description) { Q_EMIT alertReceived(pSslSocket, level, type, description); }); - connect(pSslSocket, &QSslSocket::handshakeInterruptedOnError, + connect(pSslSocket, &QSslSocket::handshakeInterruptedOnError, this, [this, pSslSocket](const QSslError &error) { Q_EMIT handshakeInterruptedOnError(pSslSocket, error); });