diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-04-07 15:23:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 15:23:39 -0700 |
commit | 03d10bb67a72153e1aca0e7c67eaf022769d75b9 (patch) | |
tree | 4ee2331f80686a01264a8b5a50ddbb6788499122 /platform/macos | |
parent | 371919555f82c4f7aeaf8eb9addad15b6851cc5b (diff) | |
download | qtlocation-mapboxgl-03d10bb67a72153e1aca0e7c67eaf022769d75b9.tar.gz |
[ios, macos] Guard against looking up annotation contexts MGLAnnotationTagNotFound (#8686)
Diffstat (limited to 'platform/macos')
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 326a70ebb2..1d24f2a6e8 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.4.1 * Fixed an issue causing code signing failures and bloating the framework. ([#8640](https://github.com/mapbox/mapbox-gl-native/pull/8640)) +* Fixed an issue that could cause a crash if annotations unknown to the map view were interacted with. ([#8686](https://github.com/mapbox/mapbox-gl-native/pull/8686)) * Renamed the "Data-Driven Styling" guide to "Using Style Functions at Runtime" and clarified the meaning of data-driven styling in the guide's discussion of runtime style functions. ([#8627](https://github.com/mapbox/mapbox-gl-native/pull/8627)) ## 0.4.0 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; } |