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

Commit 30924d9

Browse files
authored
[ASDataController] Ensure ASRangeController has an opportunity to update 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
1 parent 7872cfb commit 30924d9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

AsyncDisplayKit/Details/ASDataController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ extern NSString * const ASCollectionInvalidUpdateException;
7676
*/
7777
@protocol ASDataControllerDelegate <NSObject>
7878

79-
@optional
80-
8179
/**
8280
Called for batch update.
8381
*/
8482
- (void)dataControllerBeginUpdates:(ASDataController *)dataController;
83+
- (void)dataControllerWillDeleteAllData:(ASDataController *)dataController;
8584
- (void)dataController:(ASDataController *)dataController endUpdatesAnimated:(BOOL)animated completion:(void (^ _Nullable)(BOOL))completion;
8685

8786
/**

AsyncDisplayKit/Details/ASDataController.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ - (void)_reloadDataWithAnimationOptions:(ASDataControllerAnimationOptions)animat
452452
// -beginUpdates
453453
[_mainSerialQueue performBlockOnMainThread:^{
454454
[_delegate dataControllerBeginUpdates:self];
455+
[_delegate dataControllerWillDeleteAllData:self];
455456
}];
456457

457458
// deleteSections:

AsyncDisplayKit/Details/ASRangeController.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ - (void)dataControllerBeginUpdates:(ASDataController *)dataController
476476
[_delegate didBeginUpdatesInRangeController:self];
477477
}
478478

479+
- (void)dataControllerWillDeleteAllData:(ASDataController *)dataController
480+
{
481+
[self _setVisibleNodes:nil];
482+
}
483+
479484
- (void)dataController:(ASDataController *)dataController endUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion
480485
{
481486
ASDisplayNodeAssertMainThread();

0 commit comments

Comments
 (0)