[core] Make FeatureIndex own GeometryTileData.

Prevents querying a FeatureIndex built against a separate set of data, which can lead to invalid index exceptions.
The GeometryTileWorker 'data' member can still change independently of the data in the feature index, at the time 'setData' is called. The GeometryTileWorker maintains ownership of its local data (which may be used to re-parse) and clones the data for use by the FeatureIndex in the foreground.
This commit is contained in:
Chris Loer
2018-03-31 19:47:40 -07:00
committed by Chris Loer
parent 11961d5c31
commit a2399a57a2
5 changed files with 27 additions and 30 deletions

View File

@@ -329,7 +329,7 @@ void GeometryTileWorker::parse() {
std::unordered_map<std::string, std::unique_ptr<SymbolLayout>> symbolLayoutMap;
buckets.clear();
featureIndex = std::make_unique<FeatureIndex>();
featureIndex = std::make_unique<FeatureIndex>(*data ? (*data)->clone() : nullptr);
BucketParameters parameters { id, mode, pixelRatio };
GlyphDependencies glyphDependencies;
@@ -471,7 +471,6 @@ void GeometryTileWorker::performSymbolLayout() {
parent.invoke(&GeometryTile::onLayout, GeometryTile::LayoutResult {
std::move(buckets),
std::move(featureIndex),
*data ? (*data)->clone() : nullptr,
std::move(glyphAtlasImage),
std::move(iconAtlasImage)
}, correlationID);