summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-01-07 12:38:07 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-01-15 12:48:23 +0100
commit3f5d02ee6509e2fe0abb9bb9aa34979a3bad932c (patch)
tree31f94cab51f9421c1dfb1876f5557263efadd906 /src
parent180b3f125f191d1912d152d1064228013f39552f (diff)
downloadqtlocation-mapboxgl-3f5d02ee6509e2fe0abb9bb9aa34979a3bad932c.tar.gz
[core] use stale raster tiles
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/raster_tile_data.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mbgl/map/raster_tile_data.cpp b/src/mbgl/map/raster_tile_data.cpp
index a462b86bec..19baa26e55 100644
--- a/src/mbgl/map/raster_tile_data.cpp
+++ b/src/mbgl/map/raster_tile_data.cpp
@@ -26,23 +26,25 @@ void RasterTileData::request(const std::string& url,
FileSource* fs = util::ThreadContext::getFileSource();
req = fs->request({ Resource::Kind::Tile, url }, [url, callback, this](Response res) {
- if (res.stale) {
- // Only handle fresh responses.
- return;
- }
- req = nullptr;
-
if (res.error) {
if (res.error->reason == Response::Error::Reason::NotFound) {
+ // This is a 404 response. We're treating these as empty tiles.
+ workRequest.reset();
state = State::parsed;
+ bucket.reset();
} else {
+ // This is a different error, e.g. a connection or server error.
error = std::make_exception_ptr(std::runtime_error(res.error->message));
- state = State::obsolete;
}
callback();
return;
}
+ if (res.notModified) {
+ // We got the same data again. Abort early.
+ return;
+ }
+
if (state == State::loading) {
// Only overwrite the state when we didn't have a previous tile.
state = State::loaded;
@@ -51,6 +53,7 @@ void RasterTileData::request(const std::string& url,
modified = res.modified;
expires = res.expires;
+ workRequest.reset();
workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(texturePool), res.data, [this, callback] (RasterTileParseResult result) {
workRequest.reset();
if (state != State::loaded) {
@@ -63,6 +66,7 @@ void RasterTileData::request(const std::string& url,
} else {
error = result.get<std::exception_ptr>();
state = State::obsolete;
+ bucket.reset();
}
callback();