summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-09-20 03:03:49 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-19 18:03:49 -0700
commit72e3d6906deee2384c1610e13ac6f5cb0ee1ddc5 (patch)
tree12dd73230698d28de8bffa5ee977e38730f17433 /src
parent37cb2bd756104923c8a055277a9d598710943e9f (diff)
downloadqtlocation-mapboxgl-72e3d6906deee2384c1610e13ac6f5cb0ee1ddc5.tar.gz
[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
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp28
1 files changed, 24 insertions, 4 deletions
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;
}