From 8a9665b08546408dabc4a0a59102039fda58a503 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 10 Jul 2015 20:25:21 +0300 Subject: [PATCH] Deffer updateAnnotationTiles() if Source is not available The Style object might have been created but the Source is not yet available because the JSON file was not set. Can happen specially when the style is loaded from the network. --- src/mbgl/map/map_context.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index aff323d3f..4447ecc4f 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -150,11 +150,20 @@ void MapContext::updateAnnotationTiles(const std::unordered_set annotationManager = data.getAnnotationManager(); annotationManager->markStaleTiles(ids); - if (!style) return; + if (!style) { + return; + } // grab existing, single shape annotations source const auto& shapeID = AnnotationManager::ShapeLayerID; - style->getSource(shapeID)->enabled = true; + Source* shapeAnnotationSource = style->getSource(shapeID); + + // Style not parsed yet + if (!shapeAnnotationSource) { + return; + } + + shapeAnnotationSource->enabled = true; // create (if necessary) layers and buckets for each shape for (const auto &shapeAnnotationID : annotationManager->getOrderedShapeAnnotations()) {