From ec34813c905566bfb7a388a9d905d1e20711dc17 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Wed, 5 Apr 2017 14:16:58 -0400 Subject: [PATCH] [ios] assertion to check if an annotationTag > 0 (#8588) * [ios] assertion to check if an annotationTag > 0 * [ios,macos] assertion and guard added to check annotations in visibleAnnotationsInRect --- platform/ios/src/MGLMapView.mm | 2 ++ platform/macos/src/MGLMapView.mm | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 6f51d4b52..ef4326556 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3060,10 +3060,12 @@ public: continue; } MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); + NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag); if (annotationContext.annotation) { [annotations addObject:annotationContext.annotation]; } + } return [annotations copy]; diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 871195055..fc9834e01 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1801,7 +1801,11 @@ public: continue; } MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); - [annotations addObject:annotationContext.annotation]; + NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag); + if (annotationContext.annotation) + { + [annotations addObject:annotationContext.annotation]; + } } return [annotations copy];