diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f66775b3b..479ed1cad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ - Yoga integration improvements [Michael Schneider](https://github.com/maicki)[#1187] (https://github.com/TextureGroup/Texture/pull/1187) - Correct linePositionModifier behavior [Michael Schneider](https://github.com/maicki)[#1192] (https://github.com/TextureGroup/Texture/pull/1192) - Tweak a11y label aggregation behavior to enable container label overrides [Michael Schneider](https://github.com/maicki)[#1199] (https://github.com/TextureGroup/Texture/pull/1199) +- Fix logic cleaning data if delegate / dataSource changes and bring over logic to ASTableView [Michael Schneider](https://github.com/maicki)[#1200] (https://github.com/TextureGroup/Texture/pull/1200) ## 2.7 - Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877) diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index 62380e4891..f451c7727c 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -576,10 +576,16 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; - (void)_asyncDelegateOrDataSourceDidChange { ASDisplayNodeAssertMainThread(); - - if (_asyncDataSource == nil && _asyncDelegate == nil && _isDeallocating && ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) { - [_dataController clearData]; - } + + if (_asyncDataSource == nil && _asyncDelegate == nil) { + if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) { + if (_isDeallocating) { + [_dataController clearData]; + } + } else { + [_dataController clearData]; + } + } } - (void)setCollectionViewLayout:(nonnull UICollectionViewLayout *)collectionViewLayout diff --git a/Source/ASTableView.mm b/Source/ASTableView.mm index b88906bf89..5854410c9b 100644 --- a/Source/ASTableView.mm +++ b/Source/ASTableView.mm @@ -436,6 +436,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; _dataController.validationErrorSource = asyncDataSource; super.dataSource = (id)_proxyDataSource; + [self _asyncDelegateOrDataSourceDidChange]; } - (id)asyncDelegate @@ -506,6 +507,22 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell"; } super.delegate = (id)_proxyDelegate; + [self _asyncDelegateOrDataSourceDidChange]; +} + +- (void)_asyncDelegateOrDataSourceDidChange +{ + ASDisplayNodeAssertMainThread(); + + if (_asyncDataSource == nil && _asyncDelegate == nil) { + if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) { + if (_isDeallocating) { + [_dataController clearData]; + } + } else { + [_dataController clearData]; + } + } } - (void)proxyTargetHasDeallocated:(ASDelegateProxy *)proxy