From 180b3f125f191d1912d152d1064228013f39552f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 7 Jan 2016 12:05:51 +0100 Subject: [PATCH] [core] don't mark tiles with failed requests as obsolete Otherwise, this will remove them from the map and overwrite the old data. This could happen e.g. when we have connection trouble and a tile needs to be refreshed, or we're displaying stale information and the connection is down. --- src/mbgl/map/source.cpp | 2 +- src/mbgl/map/tile_data.hpp | 4 ++++ src/mbgl/map/vector_tile_data.cpp | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 4432b3a49..613972e93 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -531,7 +531,7 @@ void Source::tileLoadingCompleteCallback(const TileID& tileID, const TransformSt return; } - if (tileData->getState() == TileData::State::obsolete && tileData->getError()) { + if (tileData->hasError()) { observer->onTileError(*this, tileID, tileData->getError()); return; } diff --git a/src/mbgl/map/tile_data.hpp b/src/mbgl/map/tile_data.hpp index 2bb11054a..e31cced96 100644 --- a/src/mbgl/map/tile_data.hpp +++ b/src/mbgl/map/tile_data.hpp @@ -88,6 +88,10 @@ public: return state; } + bool hasError() const { + return error.operator bool(); + } + std::exception_ptr getError() const { return error; } diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index f44dc7598..ee43373a6 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -33,12 +33,16 @@ VectorTileData::VectorTileData(const TileID& id_, Seconds expires_) { if (err) { error = err; - state = State::obsolete; callback(); return; } + // Reset the error if we didn't receive one for this request. This is to prevent old error + // messages from being displayed again, e.g. after a connection trouble cleared up. + error = nullptr; + if (!tile) { + // This is a 404 response. We're treating these as empty tiles. state = State::parsed; buckets.clear(); callback();