From 95e3ecfd3c75fa8917995488e8c9539f4643d29f Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Sep 2021 20:01:04 +0200 Subject: [PATCH] prevent infinte recursion when closing a websocket in case of SSL errors the slots connected to the web socket can be called even during close and lead to infinite calls to close -> error slot -> close -> ... Signed-off-by: Matthieu Gallien --- src/libsync/pushnotifications.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libsync/pushnotifications.cpp b/src/libsync/pushnotifications.cpp index fcae8e985..8febf024d 100644 --- a/src/libsync/pushnotifications.cpp +++ b/src/libsync/pushnotifications.cpp @@ -76,6 +76,9 @@ void PushNotifications::closeWebSocket() _reconnectTimer->stop(); } + disconnect(_webSocket, QOverload::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError); + disconnect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); + _webSocket->close(); } @@ -171,6 +174,8 @@ void PushNotifications::openWebSocket() const auto webSocketUrl = capabilities.pushNotificationsWebSocketUrl(); qCInfo(lcPushNotifications) << "Open connection to websocket on" << webSocketUrl << "for account" << _account->url(); + connect(_webSocket, QOverload::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError); + connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); _webSocket->open(webSocketUrl); }