Skip to content

Commit

Permalink
Revert "Prevent deallocation of asyncDataSource and asyncDelegate in …
Browse files Browse the repository at this point in the history
…ASCollectionView and ASTableView"

This reverts commit 3668f45.
  • Loading branch information
appleguy committed Mar 22, 2016
1 parent 953c0f5 commit 5b9302b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 48 deletions.
9 changes: 1 addition & 8 deletions AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1139,14 +1139,7 @@ - (void)didMoveToWindow
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
// their update in the layout pass
if (![node supportsRangeManagedInterfaceState]) {
// Grab a strong reference for data source and delegate to be sure they are not going away while executing
// the range update. This can happen in range updates while going back in the view controller hierarchy
__block id<ASCollectionDataSource> asyncDataSource = _asyncDataSource;
__block id<ASCollectionDelegate> asyncDelegate = _asyncDelegate;
[_rangeController scheduleRangeUpdateCompletion:^{
asyncDataSource = nil;
asyncDelegate = nil;
}];
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
}
}

Expand Down
9 changes: 1 addition & 8 deletions AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1072,14 +1072,7 @@ - (void)didMoveToWindow
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
// their update in the layout pass
if (![node supportsRangeManagedInterfaceState]) {
// Grab a strong reference for data source and delegate to be sure they are not going away while executing
// the range update. This can happen in range updates while going back in the view controller hierarchy
__block id<ASTableDataSource> asyncDataSource = _asyncDataSource;
__block id<ASTableDelegate> asyncDelegate = _asyncDelegate;
[_rangeController scheduleRangeUpdateCompletion:^{
asyncDataSource = nil;
asyncDelegate = nil;
}];
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
}
}

Expand Down
23 changes: 1 addition & 22 deletions AsyncDisplayKit/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ @interface ASRangeController ()
BOOL _didUpdateCurrentRange;
BOOL _didRegisterForNotifications;
CFAbsoluteTime _pendingDisplayNodesTimestamp;
NSMutableArray *_scheduledRangeUpdateCompletionBlocks;
}

@end
Expand All @@ -47,7 +46,6 @@ - (instancetype)init
_rangeIsValid = YES;
_currentRangeMode = ASLayoutRangeModeInvalid;
_didUpdateCurrentRange = NO;
_scheduledRangeUpdateCompletionBlocks = [NSMutableArray array];

[[[self class] allRangeControllersWeakSet] addObject:self];

Expand Down Expand Up @@ -113,29 +111,15 @@ - (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode

- (void)scheduleRangeUpdate
{
[self scheduleRangeUpdateCompletion:nil];
}

- (void)scheduleRangeUpdateCompletion:(void (^)(void))completion
{
if (completion) {
[_scheduledRangeUpdateCompletionBlocks addObject:completion];
}

if (_queuedRangeUpdate) {
return;
}

// coalesce these events -- handling them multiple times per runloop is noisy and expensive
_queuedRangeUpdate = YES;

__block id<ASRangeControllerDataSource> dataSource = _dataSource;
__block id<ASRangeControllerDelegate> delegate = _delegate;
dispatch_async(dispatch_get_main_queue(), ^{
[self _updateVisibleNodeIndexPaths];

dataSource = nil;
delegate = nil;
[self performRangeUpdate];
});
}

Expand Down Expand Up @@ -336,11 +320,6 @@ - (void)_updateVisibleNodeIndexPaths
_rangeIsValid = YES;
_queuedRangeUpdate = NO;

for (void (^completionBlock)(void) in _scheduledRangeUpdateCompletionBlocks) {
completionBlock();
}
[_scheduledRangeUpdateCompletionBlocks removeAllObjects];

#if ASRangeControllerLoggingEnabled
// NSSet *visibleNodePathsSet = [NSSet setWithArray:visibleNodePaths];
// BOOL setsAreEqual = [visibleIndexPaths isEqualToSet:visibleNodePathsSet];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
*/
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode;

/**
* Schedule a range update and call the completion block if finished. This drives updating the working
* ranges, and triggering their actions.
*/
- (void)scheduleRangeUpdateCompletion:(void (^)(void))completion;

@end


Expand All @@ -70,10 +64,7 @@

@interface ASViewController (ASRangeControllerUpdateRangeProtocol)

/**
* Automatically adjust range mode based on view events if the containing node confirms to the
* ASRangeControllerUpdateRangeProtocol
*/
/// Automatically adjust range mode based on view events if the containing node confirms to the ASRangeControllerUpdateRangeProtocol
@property (nonatomic, assign) BOOL automaticallyAdjustRangeModeBasedOnViewEvents;

@end

0 comments on commit 5b9302b

Please sign in to comment.