diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-10-17 15:13:30 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-10-17 16:29:02 +0300 |
commit | 057048b293d00aed6fc964109e3bfa6bc5ba39ed (patch) | |
tree | 28c1cccfe5f56a13211fc4cbceed470604fae250 /src | |
parent | a8558379dbbc92ca75c9c3057990ac6c78a06e1f (diff) | |
download | qtlocation-mapboxgl-057048b293d00aed6fc964109e3bfa6bc5ba39ed.tar.gz |
[core] Fix image requests for already obtained images
Before this change, repeated request for an already
obtained image was erroneously treated as pending.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/image_manager.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/renderer/image_manager.hpp | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/mbgl/renderer/image_manager.cpp b/src/mbgl/renderer/image_manager.cpp index 0920f5a659..7b51fb9a2e 100644 --- a/src/mbgl/renderer/image_manager.cpp +++ b/src/mbgl/renderer/image_manager.cpp @@ -189,9 +189,12 @@ void ImageManager::checkMissingAndNotify(ImageRequestor& requestor, const ImageR auto existingRequestorsIt = requestedImages.find(missingImage); if (existingRequestorsIt != requestedImages.end()) { // Already asked client about this image. - if (!existingRequestorsIt->second.empty()) { // Still waiting for the client response. - existingRequestorsIt->second.emplace(requestorPtr); - requestor.addPendingRequest(missingImage); + std::set<ImageRequestor*>& existingRequestors = existingRequestorsIt->second; + if (!existingRequestors.empty() && + (*existingRequestors.begin()) + ->hasPendingRequest(missingImage)) { // Still waiting for the client response for this image. + requestorPtr->addPendingRequest(missingImage); + existingRequestors.emplace(requestorPtr); continue; } // Unlike icons, pattern changes are not caught diff --git a/src/mbgl/renderer/image_manager.hpp b/src/mbgl/renderer/image_manager.hpp index 98b42da838..5ed6e237f0 100644 --- a/src/mbgl/renderer/image_manager.hpp +++ b/src/mbgl/renderer/image_manager.hpp @@ -73,9 +73,8 @@ public: virtual void onImagesAvailable(ImageMap icons, ImageMap patterns, ImageVersionMap versionMap, uint64_t imageCorrelationID) = 0; void addPendingRequest(const std::string& imageId) { pendingRequests.insert(imageId); } - + bool hasPendingRequest(const std::string& imageId) const { return pendingRequests.count(imageId); } bool hasPendingRequests() const { return !pendingRequests.empty(); } - void removePendingRequest(const std::string& imageId) { pendingRequests.erase(imageId); } private: |