summaryrefslogtreecommitdiff
path: root/platform/macos/src
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-04-07 15:23:39 -0700
committerGitHub <noreply@github.com>2017-04-07 15:23:39 -0700
commit03d10bb67a72153e1aca0e7c67eaf022769d75b9 (patch)
tree4ee2331f80686a01264a8b5a50ddbb6788499122 /platform/macos/src
parent371919555f82c4f7aeaf8eb9addad15b6851cc5b (diff)
downloadqtlocation-mapboxgl-03d10bb67a72153e1aca0e7c67eaf022769d75b9.tar.gz
[ios, macos] Guard against looking up annotation contexts MGLAnnotationTagNotFound (#8686)
Diffstat (limited to 'platform/macos/src')
-rw-r--r--platform/macos/src/MGLMapView.mm11
1 files changed, 8 insertions, 3 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index a5a5c53df3..a873d9ef82 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1796,10 +1796,12 @@ public:
for (auto const& annotationTag: annotationTags)
{
- if (!_annotationContextsByAnnotationTag.count(annotationTag))
+ if (!_annotationContextsByAnnotationTag.count(annotationTag) ||
+ annotationTag == MGLAnnotationTagNotFound)
{
continue;
}
+
MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag);
if (annotationContext.annotation)
@@ -1816,7 +1818,8 @@ public:
/// Returns the annotation assigned the given tag. Cheap.
- (id <MGLAnnotation>)annotationWithTag:(MGLAnnotationTag)tag {
- if (!_annotationContextsByAnnotationTag.count(tag)) {
+ if ( ! _annotationContextsByAnnotationTag.count(tag) ||
+ tag == MGLAnnotationTagNotFound) {
return nil;
}
@@ -2147,9 +2150,11 @@ public:
}
- (id <MGLAnnotation>)selectedAnnotation {
- if (!_annotationContextsByAnnotationTag.count(_selectedAnnotationTag)) {
+ if ( ! _annotationContextsByAnnotationTag.count(_selectedAnnotationTag) ||
+ _selectedAnnotationTag == MGLAnnotationTagNotFound) {
return nil;
}
+
MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(_selectedAnnotationTag);
return annotationContext.annotation;
}