Переглянути джерело

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 8 роки тому
батько
коміт
7e68abba5c
1 змінених файлів з 2 додано та 1 видалено
  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();