summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-08-26 13:11:33 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-06 12:52:13 -0700
commit21dc12ee93e890325c61daa0e4183dd1e795f0a9 (patch)
tree4c8cb22c5f5f7613dbb5126c481e3086b0d048a3
parent5b8d90bf0073c29790e9acaaf12471296de054ff (diff)
downloadqtlocation-mapboxgl-21dc12ee93e890325c61daa0e4183dd1e795f0a9.tar.gz
[core] Ensure that TileWorker can retain tileData after layout
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp4
-rw-r--r--src/mbgl/annotation/annotation_tile.hpp1
-rw-r--r--src/mbgl/tile/geojson_tile.cpp4
-rw-r--r--src/mbgl/tile/geometry_tile.cpp2
-rw-r--r--src/mbgl/tile/geometry_tile_data.hpp1
-rw-r--r--src/mbgl/tile/tile_worker.cpp2
-rw-r--r--src/mbgl/tile/vector_tile.cpp4
7 files changed, 17 insertions, 1 deletions
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index 6b225ce20b..c9ad9b5214 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -40,6 +40,10 @@ optional<Value> AnnotationTileFeature::getValue(const std::string& key) const {
AnnotationTileLayer::AnnotationTileLayer(std::string name_)
: name(std::move(name_)) {}
+std::unique_ptr<GeometryTileData> AnnotationTileData::clone() const {
+ return std::make_unique<AnnotationTileData>(*this);
+}
+
const GeometryTileLayer* AnnotationTileData::getLayer(const std::string& name) const {
auto it = layers.find(name);
if (it != layers.end()) {
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp
index 19a731ee7b..d43ec82d38 100644
--- a/src/mbgl/annotation/annotation_tile.hpp
+++ b/src/mbgl/annotation/annotation_tile.hpp
@@ -56,6 +56,7 @@ private:
class AnnotationTileData : public GeometryTileData {
public:
+ std::unique_ptr<GeometryTileData> clone() const override;
const GeometryTileLayer* getLayer(const std::string&) const override;
std::unordered_map<std::string, AnnotationTileLayer> layers;
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index bba347f39d..5dc099de69 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -55,6 +55,10 @@ public:
: features(std::move(features_)) {
}
+ std::unique_ptr<GeometryTileData> clone() const override {
+ return std::make_unique<GeoJSONTileData>(*this);
+ }
+
const GeometryTileLayer* getLayer(const std::string&) const override {
return this;
}
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index e4e2085d05..bd2d8f760f 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -66,6 +66,8 @@ void GeometryTile::setData(std::unique_ptr<const GeometryTileData> data_) {
workRequest.reset();
availableData = DataAvailability::All;
buckets.clear();
+ featureIndex.reset();
+ data.reset();
redoPlacement();
observer->onTileLoaded(*this, true);
return;
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp
index 2714b139ed..8a10ec058a 100644
--- a/src/mbgl/tile/geometry_tile_data.hpp
+++ b/src/mbgl/tile/geometry_tile_data.hpp
@@ -51,6 +51,7 @@ public:
class GeometryTileData {
public:
virtual ~GeometryTileData() = default;
+ virtual std::unique_ptr<GeometryTileData> clone() const = 0;
virtual const GeometryTileLayer* getLayer(const std::string&) const = 0;
};
diff --git a/src/mbgl/tile/tile_worker.cpp b/src/mbgl/tile/tile_worker.cpp
index 5761ca83b9..0c90456da0 100644
--- a/src/mbgl/tile/tile_worker.cpp
+++ b/src/mbgl/tile/tile_worker.cpp
@@ -95,7 +95,7 @@ TileParseResult TileWorker::prepareResult(const PlacementConfig& config) {
if (result.complete) {
featureIndex->setCollisionTile(placeLayers(config));
result.featureIndex = std::move(featureIndex);
- result.tileData = std::move(tileData);
+ result.tileData = tileData->clone();
}
return std::move(result);
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index c388a60cbb..4a1f60711c 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -59,6 +59,10 @@ class VectorTileData : public GeometryTileData {
public:
VectorTileData(std::shared_ptr<const std::string> data);
+ std::unique_ptr<GeometryTileData> clone() const override {
+ return std::make_unique<VectorTileData>(*this);
+ }
+
const GeometryTileLayer* getLayer(const std::string&) const override;
private: