[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
This commit is contained in:
committed by
Minh Nguyễn
parent
f0d4411871
commit
937fa0ce44
@@ -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))
|
||||
|
||||
@@ -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"];
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user