From 72e3d6906deee2384c1610e13ac6f5cb0ee1ddc5 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 20 Sep 2016 03:03:49 +0200 Subject: [android] - do not update marker while creating (#6314) * [android] - do not update marker while creating, add activity to prevent regression * [core] - add asserts to incorrect usage of update and remove annotations api * [android] - fix marker tests --- src/mbgl/annotation/annotation_manager.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 28a97d292e..63adf9de2a 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -40,7 +40,9 @@ AnnotationManager::~AnnotationManager() = default; AnnotationID AnnotationManager::addAnnotation(const Annotation& annotation, const uint8_t maxZoom) { AnnotationID id = nextID++; - updateAnnotation(id, annotation, maxZoom); + Annotation::visit(annotation, [&] (const auto& annotation_) { + this->add(id, annotation_, maxZoom); + }); return id; } @@ -57,6 +59,8 @@ void AnnotationManager::removeAnnotation(const AnnotationID& id) { } else if (shapeAnnotations.find(id) != shapeAnnotations.end()) { obsoleteShapeAnnotationLayers.insert(shapeAnnotations.at(id)->layerID); shapeAnnotations.erase(id); + } else { + assert(false); // Should never happen } } @@ -85,13 +89,14 @@ void AnnotationManager::add(const AnnotationID& id, const StyleSourcedAnnotation } Update AnnotationManager::update(const AnnotationID& id, const SymbolAnnotation& annotation, const uint8_t maxZoom) { + Update result = Update::Nothing; + auto it = symbolAnnotations.find(id); if (it == symbolAnnotations.end()) { - removeAndAdd(id, annotation, maxZoom); - return Update::AnnotationData | Update::AnnotationStyle; + assert(false); // Attempt to update a non-existent symbol annotation + return result; } - Update result = Update::Nothing; const SymbolAnnotation& existing = it->second->annotation; if (existing.geometry != annotation.geometry) { @@ -110,16 +115,31 @@ Update AnnotationManager::update(const AnnotationID& id, const SymbolAnnotation& } Update AnnotationManager::update(const AnnotationID& id, const LineAnnotation& annotation, const uint8_t maxZoom) { + auto it = shapeAnnotations.find(id); + if (it == shapeAnnotations.end()) { + assert(false); // Attempt to update a non-existent shape annotation + return Update::Nothing; + } removeAndAdd(id, annotation, maxZoom); return Update::AnnotationData | Update::AnnotationStyle; } Update AnnotationManager::update(const AnnotationID& id, const FillAnnotation& annotation, const uint8_t maxZoom) { + auto it = shapeAnnotations.find(id); + if (it == shapeAnnotations.end()) { + assert(false); // Attempt to update a non-existent shape annotation + return Update::Nothing; + } removeAndAdd(id, annotation, maxZoom); return Update::AnnotationData | Update::AnnotationStyle; } Update AnnotationManager::update(const AnnotationID& id, const StyleSourcedAnnotation& annotation, const uint8_t maxZoom) { + auto it = shapeAnnotations.find(id); + if (it == shapeAnnotations.end()) { + assert(false); // Attempt to update a non-existent shape annotation + return Update::Nothing; + } removeAndAdd(id, annotation, maxZoom); return Update::AnnotationData | Update::AnnotationStyle; } -- cgit v1.2.1