]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
WebsocketClient: fix potential crash
authortobtoht <thotbot@protonmail.com>
Fri, 11 Mar 2022 15:03:06 +0000 (16:03 +0100)
committertobtoht <thotbot@protonmail.com>
Fri, 11 Mar 2022 15:03:06 +0000 (16:03 +0100)
src/utils/WebsocketClient.cpp
src/utils/WebsocketClient.h

index 948954a44fd9b40e93461e3bc7d9b3242456579a..2b795a733f1fceda36e97e4bd4a87f44bb848acd 100644 (file)
@@ -117,3 +117,9 @@ void WebsocketClient::onbinaryMessageReceived(const QByteArray &message) {
 
     emit WSMessage(object);
 }
+
+WebsocketClient::~WebsocketClient() {
+    // webSocket may fire QWebSocket::disconnected after WebsocketClient is destroyed
+    // explicitly disconnect to prevent crash
+    webSocket.disconnect();
+}
\ No newline at end of file
index ca53be602377845458658c2b73741c525de0a8e6..1563f448254906b9acb935bd7a725231b429efe7 100644 (file)
@@ -15,6 +15,7 @@ class WebsocketClient : public QObject {
 
 public:
     explicit WebsocketClient(QObject *parent = nullptr);
+    ~WebsocketClient() override;
     void start();
     void restart();
     void stop();