summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/default/src/mbgl/storage/main_resource_loader.cpp6
-rw-r--r--src/mbgl/sprite/sprite_loader.cpp6
2 files changed, 9 insertions, 3 deletions
diff --git a/platform/default/src/mbgl/storage/main_resource_loader.cpp b/platform/default/src/mbgl/storage/main_resource_loader.cpp
index 9bdf09fa10..aa8d745170 100644
--- a/platform/default/src/mbgl/storage/main_resource_loader.cpp
+++ b/platform/default/src/mbgl/storage/main_resource_loader.cpp
@@ -81,13 +81,17 @@ public:
callback(response);
// Set the priority of existing resource to low if it's expired but usable.
res.setPriority(Resource::Priority::Low);
+ } else {
+ // Set prior data only if it was not returned to the requester.
+ // Once we get 304 response from the network, we will forward response
+ // to the requester.
+ res.priorData = response.data;
}
// Copy response fields for cache control request
res.priorModified = response.modified;
res.priorExpires = response.expires;
res.priorEtag = response.etag;
- res.priorData = response.data;
}
tasks[req] = requestFromNetwork(res, std::move(tasks[req]));
diff --git a/src/mbgl/sprite/sprite_loader.cpp b/src/mbgl/sprite/sprite_loader.cpp
index 56f7abd50b..60bab2bf6e 100644
--- a/src/mbgl/sprite/sprite_loader.cpp
+++ b/src/mbgl/sprite/sprite_loader.cpp
@@ -60,7 +60,8 @@ void SpriteLoader::load(const std::string& url, FileSource& fileSource) {
emitSpriteLoadedIfComplete();
} else {
// Only trigger a sprite loaded event we got new data.
- loader->json = res.data;
+ assert(loader->json != res.data);
+ loader->json = std::move(res.data);
emitSpriteLoadedIfComplete();
}
});
@@ -74,7 +75,8 @@ void SpriteLoader::load(const std::string& url, FileSource& fileSource) {
loader->image = std::make_shared<std::string>();
emitSpriteLoadedIfComplete();
} else {
- loader->image = res.data;
+ assert(loader->image != res.data);
+ loader->image = std::move(res.data);
emitSpriteLoadedIfComplete();
}
});