From 1a9ab408017cccbd312a2559ae37237aa0f14ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Wed, 1 Apr 2020 00:59:14 -0700 Subject: [PATCH] [ios] Avoid removing annotations from torn-down map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the underlying mbgl::Map has been torn down, so has the mbgl annotation, so don’t worry about the mbgl::Map but keep unregistering KVO and other SDK-side annotation resources. --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 9835d0b89..ff34a959b 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -30,6 +30,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Other changes * Added the `MGLMapView.minimumPitch` and `MGLMapView.maximumPitch` properties to further limit how much the user or your code can tilt the map. ([#208](https://github.com/mapbox/mapbox-gl-native-ios/pull/208)) +* Fixed a crash while quitting the application after adding an annotation to `MGLMapView`. ([#252](https://github.com/mapbox/mapbox-gl-native-ios/pull/252)) * Improved performance when continuously animating a tilted map. ([#16287](https://github.com/mapbox/mapbox-gl-native/pull/16287)) * Fixed a memory leak when zooming with any options enabled in the `MGLMapView.debugMask` property. ([#15179](https://github.com/mapbox/mapbox-gl-native/issues/15179)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index ab0eba259..f12354f4d 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4612,7 +4612,12 @@ public: } _isChangingAnnotationLayers = YES; - self.mbglMap.removeAnnotation(annotationTag); + // If the underlying map is gone, there’s nothing to remove, but still + // continue to unregister KVO and other annotation resources. + if (_mbglMap) + { + self.mbglMap.removeAnnotation(annotationTag); + } } [self updatePresentsWithTransaction];