Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

* Fixed some retain cycles that were preventing the RMMapView from deallocating #248

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MapView/Map/RMAnnotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@
#pragma mark -

// Used internally
@property (nonatomic, strong) RMMapView *mapView;
@property (nonatomic, weak) RMMapView *mapView;

@end
2 changes: 1 addition & 1 deletion MapView/Map/RMMapTiledLayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

@implementation RMMapTiledLayerView
{
RMMapView *_mapView;
__weak RMMapView *_mapView;
id <RMTileSource> _tileSource;
}

Expand Down
19 changes: 5 additions & 14 deletions MapView/Map/RMMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ @interface RMAnnotation (PrivateMethods)

@implementation RMMapView
{
id <RMMapViewDelegate> _delegate;

BOOL _delegateHasBeforeMapMove;
BOOL _delegateHasAfterMapMove;
BOOL _delegateHasBeforeMapZoom;
Expand Down Expand Up @@ -179,7 +177,7 @@ @implementation RMMapView
UIImageView *_userHeadingTrackingView;
UIImageView *_userHaloTrackingView;

UIViewController *_viewControllerPresentingAttribution;
__weak UIViewController *_viewControllerPresentingAttribution;
UIButton *_attributionButton;

CGAffineTransform _mapTransform;
Expand Down Expand Up @@ -506,11 +504,6 @@ - (NSString *)description
#pragma mark -
#pragma mark Delegate

- (id <RMMapViewDelegate>)delegate
{
return _delegate;
}

- (void)setDelegate:(id <RMMapViewDelegate>)aDelegate
{
if (_delegate == aDelegate)
Expand Down Expand Up @@ -601,25 +594,23 @@ - (void)registerZoomEventByUser:(BOOL)wasUserEvent
{
BOOL flag = wasUserEvent;

if ([_zoomDelegateQueue operationCount] == 0)
if ([_zoomDelegateQueue operationCount] == 0 && _delegateHasBeforeMapZoom)
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
if (_delegateHasBeforeMapZoom)
[_delegate beforeMapZoom:self byUser:flag];
[_delegate beforeMapZoom:self byUser:flag];
});
}

[_zoomDelegateQueue setSuspended:YES];

if ([_zoomDelegateQueue operationCount] == 0)
if ([_zoomDelegateQueue operationCount] == 0 && _delegateHasAfterMapZoom)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two changes related to checking the delegate before queueing the block have me concerned since they change the actual behavior order when trying to just get rid of a retain cycles. Will adapt.

{
[_zoomDelegateQueue addOperationWithBlock:^(void)
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
if (_delegateHasAfterMapZoom)
[_delegate afterMapZoom:self byUser:flag];
[_delegate afterMapZoom:self byUser:flag];
});
}];
}
Expand Down
4 changes: 2 additions & 2 deletions MapView/Map/RMQuadTree.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ @implementation RMQuadTreeNode
NSMutableArray *_annotations;
RMQuadTreeNode *_parentNode, *_northWest, *_northEast, *_southWest, *_southEast;
RMQuadTreeNodeType _nodeType;
RMMapView *_mapView;
__weak RMMapView *_mapView;

RMAnnotation *_cachedClusterAnnotation;
NSArray *_cachedClusterEnclosedAnnotations;
Expand Down Expand Up @@ -596,7 +596,7 @@ - (void)removeUpwardsAllCachedClusterAnnotations
@implementation RMQuadTree
{
RMQuadTreeNode *_rootNode;
RMMapView *_mapView;
__weak RMMapView *_mapView;
}

- (id)initWithMapView:(RMMapView *)aMapView
Expand Down