summaryrefslogtreecommitdiff
path: root/platform/macos/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-04-04 21:08:50 -0700
committerMinh Nguyễn <mxn@1ec5.org>2017-04-05 14:56:06 -0700
commitd39ea23b0975bf39f54bb181b14f3caed69a4767 (patch)
treeb7a136dbedacc5ce82b6330c96a70a31ad2b8718 /platform/macos/src
parent5bfbe9603b8f306e8725ef54a642e3fa57fe9141 (diff)
downloadqtlocation-mapboxgl-d39ea23b0975bf39f54bb181b14f3caed69a4767.tar.gz
[ios, macos] Hardened std::map usage in MGLMapVIew
Replaced std::map::operator[] usage with std::map::at(). Backed up an assertion on iOS with a guard when -annotationTagsInRect: returns the tag of a nonexistent annotation, for consistency with macOS. Removed an unnecessary and risky subscript into _annotationContextsByAnnotationTag in -positioningRectForCalloutForAnnotationWithTag: on iOS.
Diffstat (limited to 'platform/macos/src')
-rw-r--r--platform/macos/src/MGLMapView.mm4
1 files changed, 2 insertions, 2 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index fc9834e016..a5a5c53df3 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1820,7 +1820,7 @@ public:
return nil;
}
- MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag[tag];
+ MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);
return annotationContext.annotation;
}
@@ -2057,8 +2057,8 @@ public:
// Filter out any annotation whose image is unselectable or for which
// hit testing fails.
auto end = std::remove_if(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MGLAnnotationTag annotationTag) {
- NSAssert(_annotationContextsByAnnotationTag.count(annotationTag) != 0, @"Unknown annotation found nearby click");
id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag];
+ NSAssert(annotation, @"Unknown annotation found nearby click");
if (!annotation) {
return true;
}