summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/geometry_tile.cpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-03-31 19:47:40 -0700
committerChris Loer <chris.loer@mapbox.com>2018-04-02 10:39:22 -0700
commita2399a57a22aa453dbc5a9b16244bbc953e2d632 (patch)
treee720e97a330fc7579bef67c17dd4219c92fe6f16 /src/mbgl/tile/geometry_tile.cpp
parent11961d5c31e6ec245823b583a4dc5e1b12dd7f5a (diff)
downloadqtlocation-mapboxgl-a2399a57a22aa453dbc5a9b16244bbc953e2d632.tar.gz
[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.
Diffstat (limited to 'src/mbgl/tile/geometry_tile.cpp')
-rw-r--r--src/mbgl/tile/geometry_tile.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 5089f95022..a99cb91d26 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -133,7 +133,7 @@ void GeometryTile::onLayout(LayoutResult result, const uint64_t resultCorrelatio
buckets = std::move(result.buckets);
- dataPendingCommit = {{ std::move(result.tileData), std::move(result.featureIndex) }};
+ featureIndexPendingCommit = { std::move(result.featureIndex) };
if (result.glyphAtlasImage) {
glyphAtlasImage = std::move(*result.glyphAtlasImage);
@@ -202,12 +202,11 @@ Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const {
}
void GeometryTile::commitFeatureIndex() {
- // We commit our pending FeatureIndex and GeometryTileData when a global placement has run,
- // synchronizing the global CollisionIndex with the latest buckets/FeatureIndex/GeometryTileData
- if (dataPendingCommit) {
- data = std::move(dataPendingCommit->first);
- featureIndex = std::move(dataPendingCommit->second);
- dataPendingCommit = nullopt;
+ // We commit our pending FeatureIndex when a global placement has run,
+ // synchronizing the global CollisionIndex with the latest buckets/FeatureIndex
+ if (featureIndexPendingCommit) {
+ featureIndex = std::move(*featureIndexPendingCommit);
+ featureIndexPendingCommit = nullopt;
}
}
@@ -219,7 +218,7 @@ void GeometryTile::queryRenderedFeatures(
const RenderedQueryOptions& options,
const CollisionIndex& collisionIndex) {
- if (!featureIndex || !data) return;
+ if (!getData()) return;
// Determine the additional radius needed factoring in property functions
float additionalRadius = 0;
@@ -236,7 +235,6 @@ void GeometryTile::queryRenderedFeatures(
util::tileSize * id.overscaleFactor(),
std::pow(2, transformState.getZoom() - id.overscaledZ),
options,
- *data,
id.toUnwrapped(),
sourceID,
layers,
@@ -248,8 +246,8 @@ void GeometryTile::querySourceFeatures(
std::vector<Feature>& result,
const SourceQueryOptions& options) {
- // Data not yet available
- if (!data) {
+ // Data not yet available, or tile is empty
+ if (!getData()) {
return;
}
@@ -262,7 +260,7 @@ void GeometryTile::querySourceFeatures(
for (auto sourceLayer : *options.sourceLayers) {
// Go throught all sourceLayers, if any
// to gather all the features
- auto layer = data->getLayer(sourceLayer);
+ auto layer = getData()->getLayer(sourceLayer);
if (layer) {
auto featureCount = layer->featureCount();