Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[Qt] Connect to finished() and error() signals from QNetworkReply
Browse files Browse the repository at this point in the history
Qt macOS network manage implementation differs from linux in a sense
that some requests do not generate a finished() signal, but a error()
instead - that is not caught up by the network access manager. This
made QMapboxGL.styleURL utest hang for macOS.
  • Loading branch information
brunoabinader authored and tmpsantos committed Sep 28, 2016
1 parent 4ef66f3 commit 55c4bb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions platform/qt/src/http_file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ HTTPFileSource::Impl::Impl() : m_manager(new QNetworkAccessManager(this))
if (m_ssl.caCertificates().isEmpty()) {
mbgl::Log::Warning(mbgl::Event::HttpRequest, "Could not load list of certificate authorities");
}

connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinish(QNetworkReply*)));
}

void HTTPFileSource::Impl::request(HTTPRequest* req)
Expand All @@ -54,6 +52,8 @@ void HTTPFileSource::Impl::request(HTTPRequest* req)
networkRequest.setSslConfiguration(m_ssl);

data.first = m_manager->get(networkRequest);
connect(data.first, SIGNAL(finished()), this, SLOT(onReplyFinished()));
connect(data.first, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyFinished()));
}

void HTTPFileSource::Impl::cancel(HTTPRequest* req)
Expand Down Expand Up @@ -90,9 +90,10 @@ void HTTPFileSource::Impl::cancel(HTTPRequest* req)
}
}

void HTTPFileSource::Impl::replyFinish(QNetworkReply* reply)
void HTTPFileSource::Impl::onReplyFinished()
{
const QUrl& url = reply->request().url();
QNetworkReply* reply = qobject_cast<QNetworkReply *>(sender());
const QUrl& url = reply->url();

auto it = m_pending.find(url);
if (it == m_pending.end()) {
Expand Down
2 changes: 1 addition & 1 deletion platform/qt/src/http_file_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HTTPFileSource::Impl : public QObject
void cancel(HTTPRequest *);

public slots:
void replyFinish(QNetworkReply *);
void onReplyFinished();

private:
QMap<QUrl, QPair<QNetworkReply *, QVector<HTTPRequest *>>> m_pending;
Expand Down

0 comments on commit 55c4bb9

Please sign in to comment.