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

Commit

Permalink
[ASDataController] Ensure ASRangeController has an opportunity to upd…
Browse files Browse the repository at this point in the history
…ate visible nodes before they're deleted by -reloadData path. (#2815)

This change is specific to the reloadData path, which had the last-known occurrence of "deallocated while marked visible".

#2711
  • Loading branch information
appleguy authored Dec 22, 2016
1 parent 7872cfb commit 30924d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions AsyncDisplayKit/Details/ASDataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ extern NSString * const ASCollectionInvalidUpdateException;
*/
@protocol ASDataControllerDelegate <NSObject>

@optional

/**
Called for batch update.
*/
- (void)dataControllerBeginUpdates:(ASDataController *)dataController;
- (void)dataControllerWillDeleteAllData:(ASDataController *)dataController;
- (void)dataController:(ASDataController *)dataController endUpdatesAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL))completion;

/**
Expand Down
1 change: 1 addition & 0 deletions AsyncDisplayKit/Details/ASDataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ - (void)_reloadDataWithAnimationOptions:(ASDataControllerAnimationOptions)animat
// -beginUpdates
[_mainSerialQueue performBlockOnMainThread:^{
[_delegate dataControllerBeginUpdates:self];
[_delegate dataControllerWillDeleteAllData:self];
}];

// deleteSections:
Expand Down
5 changes: 5 additions & 0 deletions AsyncDisplayKit/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ - (void)dataControllerBeginUpdates:(ASDataController *)dataController
[_delegate didBeginUpdatesInRangeController:self];
}

- (void)dataControllerWillDeleteAllData:(ASDataController *)dataController
{
[self _setVisibleNodes:nil];
}

- (void)dataController:(ASDataController *)dataController endUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion
{
ASDisplayNodeAssertMainThread();
Expand Down

0 comments on commit 30924d9

Please sign in to comment.