Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Removed implicit retain.
Browse files Browse the repository at this point in the history
Adjusted multiple snapshot for snapshotter retention & lat/lon path.
  • Loading branch information
Julian Rex committed May 16, 2018
1 parent 7638a16 commit 4f2970b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion platform/darwin/src/MGLMapSnapshotter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ - (void)startWithQueue:(dispatch_queue_t)queue completionHandler:(MGLMapSnapshot
#endif
[strongSelf drawAttributedSnapshot:attributions snapshotImage:mglImage pointForFn:pointForFn queue:queue completionHandler:completion];
}
_snapshotCallback = NULL;
strongSelf->_snapshotCallback = NULL;
});

// Launches snapshot on background Thread owned by mbglMapSnapshotter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,17 @@ - (void)testMultipleSnapshotters {
for (size_t run = 0; run < numSnapshots; run++) {

float ratio = (float)run/(float)numSnapshots;
float latlon = (ratio*30.0) + ((1-ratio)*40.0);
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(latlon, latlon);
float lon = (ratio*120.0) + ((1.0-ratio)*54.0);
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(57.0, lon);

MGLMapSnapshotter *snapshotter = snapshotterWithCoordinates(coord, size);
XCTAssertNotNil(snapshotter);
__block MGLMapSnapshotter *snapshotter;

// Allocate from an autorelease pool here, to avoid having
// snapshotter retained for longer than we'd like to test.
@autoreleasepool {
snapshotter = snapshotterWithCoordinates(coord, size);
XCTAssertNotNil(snapshotter);
}

[snapshotter startWithCompletionHandler:^(MGLMapSnapshot * _Nullable snapshot, NSError * _Nullable error) {

Expand All @@ -216,6 +222,13 @@ - (void)testMultipleSnapshotters {
XCTAttachment *attachment = [XCTAttachment attachmentWithImage:snapshot.image];
attachment.lifetime = XCTAttachmentLifetimeKeepAlways;
[strongself addAttachment:attachment];

// Dealloc the snapshotter (by having this line in the block, we
// also retained the snapshotter. Setting to nil should release, as
// this block should be the only thing retaining it (since it was
// allocated from the above autorelease pool)
snapshotter = nil;

[expectation fulfill];
}];
} // end for loop
Expand Down

0 comments on commit 4f2970b

Please sign in to comment.