[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.
This commit is contained in:
Konstantin Käfer
2016-01-07 12:05:51 +01:00
parent 5fe586633c
commit 180b3f125f
3 changed files with 10 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -88,6 +88,10 @@ public:
return state;
}
bool hasError() const {
return error.operator bool();
}
std::exception_ptr getError() const {
return error;
}

View File

@@ -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();