Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] normalize TileData::State::obsolete handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed May 25, 2016
1 parent c52a0c6 commit c91e4ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/mbgl/tile/raster_tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RasterTileData::RasterTileData(const OverscaledTileID& id_,
bucket = std::move(result.get<std::unique_ptr<Bucket>>());
} else {
error = result.get<std::exception_ptr>();
state = State::obsolete;
state = State::parsed;
bucket.reset();
}

Expand All @@ -66,9 +66,7 @@ Bucket* RasterTileData::getBucket(StyleLayer const&) {
}

void RasterTileData::cancel() {
if (state != State::obsolete) {
state = State::obsolete;
}
state = State::obsolete;
req = nullptr;
workRequest.reset();
}
11 changes: 3 additions & 8 deletions src/mbgl/tile/vector_tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
workRequest.reset();
workRequest = worker.parseGeometryTile(tileWorker, style.getLayers(), std::move(tile), targetConfig, [callback, this, config = targetConfig] (TileParseResult result) {
workRequest.reset();
if (state == State::obsolete) {
return;
}

std::exception_ptr error;
if (result.is<TileParseResultData>()) {
Expand All @@ -85,8 +82,9 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
}

} else {
// This is triggered when parsing fails (e.g. due to an invalid vector tile)
error = result.get<std::exception_ptr>();
state = State::obsolete;
state = State::parsed;
}

callback(error);
Expand All @@ -107,9 +105,6 @@ bool VectorTileData::parsePending(std::function<void(std::exception_ptr)> callba
workRequest.reset();
workRequest = worker.parsePendingGeometryTileLayers(tileWorker, targetConfig, [this, callback, config = targetConfig] (TileParseResult result) {
workRequest.reset();
if (state == State::obsolete) {
return;
}

std::exception_ptr error;
if (result.is<TileParseResultData>()) {
Expand All @@ -133,7 +128,7 @@ bool VectorTileData::parsePending(std::function<void(std::exception_ptr)> callba

} else {
error = result.get<std::exception_ptr>();
state = State::obsolete;
state = State::parsed;
}

callback(error);
Expand Down

0 comments on commit c91e4ee

Please sign in to comment.