summaryrefslogtreecommitdiff
path: root/platform/macos
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-11-07 23:04:52 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-11-08 22:51:05 -0800
commitf2ba2b2deea7f832e575db652851dc7f5787309d (patch)
tree578adec77968b00439fe4a75531ce329c4150970 /platform/macos
parentb91bbbef10525ba183f3ba23ffe9e57ed829db21 (diff)
downloadqtlocation-mapboxgl-f2ba2b2deea7f832e575db652851dc7f5787309d.tar.gz
[ios, macos] Fixed crash getting annotation view
Streamlined -[MGLMapView annotationTagForAnnotation:] to use the mapping added in #5987. Reverted an unsafe access into that mapping that was added in #5987; returning nil is preferable when no such annotation can be found. Return the user location annotation view when given the user location annotation.
Diffstat (limited to 'platform/macos')
-rw-r--r--platform/macos/src/MGLMapView.mm9
1 files changed, 2 insertions, 7 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index bacba265f5..c50d3d5642 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1667,16 +1667,11 @@ public:
/// Returns the annotation tag assigned to the given annotation. Relatively expensive.
- (MGLAnnotationTag)annotationTagForAnnotation:(id <MGLAnnotation>)annotation {
- if (!annotation) {
+ if (!annotation || _annotationTagsByAnnotation.count(annotation) == 0) {
return MGLAnnotationTagNotFound;
}
- for (auto &pair : _annotationContextsByAnnotationTag) {
- if (pair.second.annotation == annotation) {
- return pair.first;
- }
- }
- return MGLAnnotationTagNotFound;
+ return _annotationTagsByAnnotation.at(annotation);
}
- (void)addAnnotation:(id <MGLAnnotation>)annotation {