summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielmatzke <github@leetvision.com>2017-02-07 01:02:35 +0100
committerMinh Nguyễn <mxn@1ec5.org>2017-02-06 16:02:35 -0800
commit937fa0ce44df02d8c3fd0ff19bf104636a9c8bf3 (patch)
tree7874c1c6e5e698933a6f228befe1104db59cf64a
parentf0d4411871d43012dc9e24a376ebc70ec6ca9224 (diff)
downloadqtlocation-mapboxgl-937fa0ce44df02d8c3fd0ff19bf104636a9c8bf3.tar.gz
[ios, macos] 7955 fix MGLMapView leaks MGLReachability objects (and threads) (#7956)
* fix MGLMapView leaks MGLReachability objects (and threads) * fix leak of MGLReachability objects and threads in MGLMapView.commonInit * update changelogs
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm10
-rw-r--r--platform/macos/CHANGELOG.md1
-rw-r--r--platform/macos/src/MGLMapView.mm13
4 files changed, 19 insertions, 6 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 9f0bc3af1c..e654f1d720 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -102,6 +102,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
### Networking and offline maps
+* Fixed a leak of MGLReachability objects and threads in MGLMapView. ([#7956](https://github.com/mapbox/mapbox-gl-native/pull/7956))
* Fixed an issue preventing an MGLMapView from loading tiles while an offline pack is downloading. ([#6446](https://github.com/mapbox/mapbox-gl-native/pull/6446))
* Fixed a crash that could occur when the device is disconnected while downloading an offline pack. ([#6293](https://github.com/mapbox/mapbox-gl-native/pull/6293))
* Fixed a crash that occurred when encountering a rate-limit error in response to a network request. ([#6223](https://github.com/mapbox/mapbox-gl-native/pull/6223))
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 35ad583081..0c438d5606 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -314,6 +314,8 @@ public:
MGLCompassDirectionFormatter *_accessibilityCompassFormatter;
NS_ARRAY_OF(MGLAttributionInfo *) *_attributionInfos;
+
+ MGLReachability *_reachability;
}
#pragma mark - Setup & Teardown -
@@ -440,12 +442,12 @@ public:
name:kMGLReachabilityChangedNotification
object:nil];
- MGLReachability* reachability = [MGLReachability reachabilityForInternetConnection];
- if ([reachability isReachable])
+ _reachability = [MGLReachability reachabilityForInternetConnection];
+ if ([_reachability isReachable])
{
_isWaitingForRedundantReachableNotification = YES;
}
- [reachability startNotifier];
+ [_reachability startNotifier];
// Set up annotation management and selection state.
_annotationImagesByIdentifier = [NSMutableDictionary dictionary];
@@ -664,6 +666,8 @@ public:
- (void)dealloc
{
+ [_reachability stopNotifier];
+
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_attributionButton removeObserver:self forKeyPath:@"hidden"];
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index 0e68a50e21..638b249cba 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -84,6 +84,7 @@ This version of the Mapbox macOS SDK corresponds to version 3.4.0 of the Mapbox
### Networking and offline maps
+* Fixed a leak of MGLReachability objects and threads in MGLMapView. ([#7956](https://github.com/mapbox/mapbox-gl-native/pull/7956))
* Fixed an issue preventing an MGLMapView from loading tiles while an offline pack is downloading. ([#6446](https://github.com/mapbox/mapbox-gl-native/pull/6446))
* Fixed an issue causing an MGLOfflinePack’s progress to continue to update after calling `-suspend`. ([#6186](https://github.com/mapbox/mapbox-gl-native/pull/6186))
* Fixed an issue preventing cached annotation images from displaying while the device is offline. ([#6358](https://github.com/mapbox/mapbox-gl-native/pull/6358))
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 86d74d768d..d687a19aed 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -193,6 +193,9 @@ public:
/// True if the view is currently printing itself.
BOOL _isPrinting;
+
+ /// reachability instance
+ MGLReachability *_reachability;
}
#pragma mark Lifecycle
@@ -273,11 +276,11 @@ public:
self.layer = _isTargetingInterfaceBuilder ? [CALayer layer] : [MGLOpenGLLayer layer];
// Notify map object when network reachability status changes.
- MGLReachability *reachability = [MGLReachability reachabilityForInternetConnection];
- reachability.reachableBlock = ^(MGLReachability *) {
+ _reachability = [MGLReachability reachabilityForInternetConnection];
+ _reachability.reachableBlock = ^(MGLReachability *) {
mbgl::NetworkStatus::Reachable();
};
- [reachability startNotifier];
+ [_reachability startNotifier];
// Install ornaments and gesture recognizers.
[self installZoomControls];
@@ -497,6 +500,10 @@ public:
}
- (void)dealloc {
+
+ [_reachability stopNotifier];
+
+
[self.window removeObserver:self forKeyPath:@"contentLayoutRect"];
[self.window removeObserver:self forKeyPath:@"titlebarAppearsTransparent"];