summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-22 12:53:19 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-22 15:43:55 -0700
commit1039f215273d8fb39d857bd6f82601f946d832c6 (patch)
tree3de8d39cf31e8261768fa9a150fe018692f0280a
parenta7527d6986418c0560c4704f8684a81ce83178db (diff)
downloadqtlocation-mapboxgl-1039f215273d8fb39d857bd6f82601f946d832c6.tar.gz
[ios, osx] Fixed dangling KVO observer crash
Fixed a crash when deallocating an MGLMapView that has point annotations. Now we explicitly remove all the annotations from the view and thus remove all remaining KVO observers on those annotations. Fixes #4805.
-rw-r--r--platform/ios/src/MGLMapView.mm3
-rw-r--r--platform/osx/src/MGLMapView.mm3
2 files changed, 6 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 9831c379a1..5ae2d79fc4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -508,6 +508,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_attributionButton removeObserver:self forKeyPath:@"hidden"];
+ // Removing the annotations unregisters any outstanding KVO observers.
+ [self removeAnnotations:self.annotations];
+
[self validateDisplayLink];
if (_mbglMap)
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm
index 6ef93b70cf..c707ef2571 100644
--- a/platform/osx/src/MGLMapView.mm
+++ b/platform/osx/src/MGLMapView.mm
@@ -450,6 +450,9 @@ public:
[self.calloutForSelectedAnnotation close];
self.calloutForSelectedAnnotation = nil;
+ // Removing the annotations unregisters any outstanding KVO observers.
+ [self removeAnnotations:self.annotations];
+
if (_mbglMap) {
delete _mbglMap;
_mbglMap = nullptr;