summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-12-16 16:21:02 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-12-17 11:31:21 +0200
commit6c2461baf9b98014a59756f02c95415980a8368c (patch)
tree3cb0a5249c8bc176d9097fc07bee4fcaffd947c3 /platform/qt
parent4016ad0f6775dff22cd9cc48371921ddd119464a (diff)
downloadqtlocation-mapboxgl-6c2461baf9b98014a59756f02c95415980a8368c.tar.gz
[qt] Fix usage of QNetworkReply after deletion
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/src/http_file_source.cpp6
-rw-r--r--platform/qt/src/http_file_source.hpp3
2 files changed, 5 insertions, 4 deletions
diff --git a/platform/qt/src/http_file_source.cpp b/platform/qt/src/http_file_source.cpp
index b8553a5a55..e4d89e3d64 100644
--- a/platform/qt/src/http_file_source.cpp
+++ b/platform/qt/src/http_file_source.cpp
@@ -20,7 +20,7 @@ void HTTPFileSource::Impl::request(HTTPRequest* req)
{
QUrl url = req->requestUrl();
- QPair<QNetworkReply*, QVector<HTTPRequest*>>& data = m_pending[url];
+ QPair<QPointer<QNetworkReply>, QVector<HTTPRequest*>>& data = m_pending[url];
QVector<HTTPRequest*>& requestsVector = data.second;
requestsVector.append(req);
@@ -45,7 +45,7 @@ void HTTPFileSource::Impl::cancel(HTTPRequest* req)
return;
}
- QPair<QNetworkReply*, QVector<HTTPRequest*>>& data = it.value();
+ QPair<QPointer<QNetworkReply>, QVector<HTTPRequest*>>& data = it.value();
QNetworkReply* reply = data.first;
QVector<HTTPRequest*>& requestsVector = data.second;
@@ -58,7 +58,7 @@ void HTTPFileSource::Impl::cancel(HTTPRequest* req)
if (requestsVector.empty()) {
m_pending.erase(it);
- reply->abort();
+ if (reply) reply->abort();
}
}
diff --git a/platform/qt/src/http_file_source.hpp b/platform/qt/src/http_file_source.hpp
index 4ba61b70da..e9c67a7fc8 100644
--- a/platform/qt/src/http_file_source.hpp
+++ b/platform/qt/src/http_file_source.hpp
@@ -7,6 +7,7 @@
#include <QNetworkAccessManager>
#include <QObject>
#include <QPair>
+#include <QPointer>
#include <QQueue>
#include <QUrl>
#include <QVector>
@@ -30,7 +31,7 @@ public slots:
void onReplyFinished();
private:
- QMap<QUrl, QPair<QNetworkReply *, QVector<HTTPRequest *>>> m_pending;
+ QMap<QUrl, QPair<QPointer<QNetworkReply>, QVector<HTTPRequest *>>> m_pending;
QNetworkAccessManager *m_manager;
};