diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-10-18 10:54:24 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-12-12 15:08:18 +0200 |
commit | 664ceb43980cb7d90a0d8b5fa1a48f83662322c9 (patch) | |
tree | d662d782fe4875a8a1b7f780a3d34f659f79acd3 /src/mbgl/renderer | |
parent | 8a03d16990b6fdde0f117def3a1b4bb2c9c92d4c (diff) | |
download | qtlocation-mapboxgl-664ceb43980cb7d90a0d8b5fa1a48f83662322c9.tar.gz |
[core] Share GeoJSONData pointer as weak_ptr instead of raw ptr
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r-- | src/mbgl/renderer/sources/render_geojson_source.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_geojson_source.hpp | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/mbgl/renderer/sources/render_geojson_source.cpp b/src/mbgl/renderer/sources/render_geojson_source.cpp index 0e265efff4..0099ebcf5e 100644 --- a/src/mbgl/renderer/sources/render_geojson_source.cpp +++ b/src/mbgl/renderer/sources/render_geojson_source.cpp @@ -33,23 +33,23 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_, enabled = needsRendering; - GeoJSONData* data_ = impl().getData(); + auto data_ = impl().getData().lock(); - if (data_ != data) { + if (data.lock() != data_) { data = data_; tilePyramid.cache.clear(); - if (data) { + if (data_) { const uint8_t maxZ = impl().getZoomRange().max; for (const auto& pair : tilePyramid.tiles) { if (pair.first.canonical.z <= maxZ) { - static_cast<GeoJSONTile*>(pair.second.get())->updateData(data->getTile(pair.first.canonical)); + static_cast<GeoJSONTile*>(pair.second.get())->updateData(data_->getTile(pair.first.canonical)); } } } } - if (!data) { + if (!data_) { tilePyramid.tiles.clear(); tilePyramid.renderTiles.clear(); return; @@ -63,8 +63,8 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_, util::tileSize, impl().getZoomRange(), optional<LatLngBounds>{}, - [&] (const OverscaledTileID& tileID) { - return std::make_unique<GeoJSONTile>(tileID, impl().id, parameters, data->getTile(tileID.canonical)); + [&, data_] (const OverscaledTileID& tileID) { + return std::make_unique<GeoJSONTile>(tileID, impl().id, parameters, data_->getTile(tileID.canonical)); }); } diff --git a/src/mbgl/renderer/sources/render_geojson_source.hpp b/src/mbgl/renderer/sources/render_geojson_source.hpp index 297fa09a29..6351c5f6f8 100644 --- a/src/mbgl/renderer/sources/render_geojson_source.hpp +++ b/src/mbgl/renderer/sources/render_geojson_source.hpp @@ -44,7 +44,7 @@ private: const style::GeoJSONSource::Impl& impl() const; TilePyramid tilePyramid; - style::GeoJSONData* data = nullptr; + std::weak_ptr<style::GeoJSONData> data; }; template <> |