Procházet zdrojové kódy

RemoteSubscriber: fix crash if connection goes away

Reproduction steps:
- open web UI
- cast a video to PMP
- close the web UI while video is still playing

m_response then will point to a dnagling pointer, and crash PMP soon
enough. This is because QHttp uses deleteLater() on the object on
disconnects.

Fix this by using QPointer, which was designed for this purpose. If the
QObject is deleted, the QPointer will be reset to NULL.
Vincent Lang před 8 roky
rodič
revize
7e68abba5c
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      src/remote/RemoteSubscriber.h

+ 2 - 1
src/remote/RemoteSubscriber.h

@@ -6,6 +6,7 @@
 #define KONVERGO_REMOTESUBSCRIBER_H
 
 #include <QObject>
+#include <QPointer>
 #include <QUrl>
 #include <QDateTime>
 #include <QDomDocument>
@@ -78,7 +79,7 @@ public:
   void sendUpdate() override;
 
 private :
-   qhttp::server::QHttpResponse* m_response;
+   QPointer<qhttp::server::QHttpResponse> m_response;
 
 public Q_SLOTS:
    void responseDone();