diff options
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_tile.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_tile.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/map_impl.cpp | 38 | ||||
-rw-r--r-- | src/mbgl/renderer/render_orchestrator.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/renderer/tile_parameters.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/update_parameters.hpp | 4 |
7 files changed, 42 insertions, 26 deletions
diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index 6c794d7f84..a9389d8ca9 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -11,6 +11,8 @@ #include <unordered_set> #include <unordered_map> +#include <mapbox/weak.hpp> + namespace mbgl { class LatLngBounds; @@ -48,6 +50,8 @@ public: static const std::string PointLayerID; static const std::string ShapeLayerID; + mapbox::base::WeakPtr<AnnotationManager> makeWeakPtr() { return weakFactory.makeWeakPtr(); } + private: void add(const AnnotationID&, const SymbolAnnotation&); void add(const AnnotationID&, const LineAnnotation&); @@ -84,6 +88,7 @@ private: ImageMap images; std::unordered_set<AnnotationTile*> tiles; + mapbox::base::WeakPtrFactory<AnnotationManager> weakFactory{this}; }; } // namespace mbgl diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp index a410adc95e..69c9f07655 100644 --- a/src/mbgl/annotation/annotation_tile.cpp +++ b/src/mbgl/annotation/annotation_tile.cpp @@ -11,11 +11,17 @@ AnnotationTile::AnnotationTile(const OverscaledTileID& overscaledTileID, const TileParameters& parameters) : GeometryTile(overscaledTileID, AnnotationManager::SourceID, parameters), annotationManager(parameters.annotationManager) { - annotationManager.addTile(*this); + auto guard = annotationManager.lock(); + if (annotationManager) { + annotationManager->addTile(*this); + } } AnnotationTile::~AnnotationTile() { - annotationManager.removeTile(*this); + auto guard = annotationManager.lock(); + if (annotationManager) { + annotationManager->removeTile(*this); + } } class AnnotationTileFeatureData { diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp index 741b598a8c..da5fc28cb6 100644 --- a/src/mbgl/annotation/annotation_tile.hpp +++ b/src/mbgl/annotation/annotation_tile.hpp @@ -15,7 +15,7 @@ public: ~AnnotationTile() override; private: - AnnotationManager& annotationManager; + mapbox::base::WeakPtr<AnnotationManager> annotationManager; }; class AnnotationTileFeatureData; diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp index af18720916..0edc715134 100644 --- a/src/mbgl/map/map_impl.cpp +++ b/src/mbgl/map/map_impl.cpp @@ -48,26 +48,24 @@ void Map::Impl::onUpdate() { transform.updateTransitions(timePoint); - UpdateParameters params = { - style->impl->isLoaded(), - mode, - pixelRatio, - debugOptions, - timePoint, - transform.getState(), - style->impl->getGlyphURL(), - style->impl->spriteLoaded, - style->impl->getTransitionOptions(), - style->impl->getLight()->impl, - style->impl->getImageImpls(), - style->impl->getSourceImpls(), - style->impl->getLayerImpls(), - annotationManager, - fileSource, - prefetchZoomDelta, - bool(stillImageRequest), - crossSourceCollisions - }; + UpdateParameters params = {style->impl->isLoaded(), + mode, + pixelRatio, + debugOptions, + timePoint, + transform.getState(), + style->impl->getGlyphURL(), + style->impl->spriteLoaded, + style->impl->getTransitionOptions(), + style->impl->getLight()->impl, + style->impl->getImageImpls(), + style->impl->getSourceImpls(), + style->impl->getLayerImpls(), + annotationManager.makeWeakPtr(), + fileSource, + prefetchZoomDelta, + bool(stillImageRequest), + crossSourceCollisions}; rendererFrontend.update(std::make_shared<UpdateParameters>(std::move(params))); } diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index c771bd100b..f00f9ee9be 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -144,7 +144,10 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree( } if (LayerManager::annotationsEnabled) { - updateParameters->annotationManager.updateData(); + auto guard = updateParameters->annotationManager.lock(); + if (updateParameters->annotationManager) { + updateParameters->annotationManager->updateData(); + } } const bool zoomChanged = diff --git a/src/mbgl/renderer/tile_parameters.hpp b/src/mbgl/renderer/tile_parameters.hpp index 6a2deee35c..147e19f146 100644 --- a/src/mbgl/renderer/tile_parameters.hpp +++ b/src/mbgl/renderer/tile_parameters.hpp @@ -4,6 +4,8 @@ #include <memory> +#include <mapbox/weak.hpp> + namespace mbgl { class TransformState; @@ -19,7 +21,7 @@ public: const TransformState& transformState; std::shared_ptr<FileSource> fileSource; const MapMode mode; - AnnotationManager& annotationManager; + mapbox::base::WeakPtr<AnnotationManager> annotationManager; ImageManager& imageManager; GlyphManager& glyphManager; const uint8_t prefetchZoomDelta; diff --git a/src/mbgl/renderer/update_parameters.hpp b/src/mbgl/renderer/update_parameters.hpp index b7aee9b572..8dd256329a 100644 --- a/src/mbgl/renderer/update_parameters.hpp +++ b/src/mbgl/renderer/update_parameters.hpp @@ -11,6 +11,8 @@ #include <vector> +#include <mapbox/weak.hpp> + namespace mbgl { class AnnotationManager; @@ -33,7 +35,7 @@ public: const Immutable<std::vector<Immutable<style::Source::Impl>>> sources; const Immutable<std::vector<Immutable<style::Layer::Impl>>> layers; - AnnotationManager& annotationManager; + mapbox::base::WeakPtr<AnnotationManager> annotationManager; std::shared_ptr<FileSource> fileSource; const uint8_t prefetchZoomDelta; |