Skip to content

Commit

Permalink
Fix logic cleaning data if delegate / dataSource changes and bring ov…
Browse files Browse the repository at this point in the history
…er logic to ASTableView (#1200)

* Cleanup in ASTableView datasource/delegate change

* Fix experiments logic

* Add changelog entry
  • Loading branch information
maicki committed Nov 1, 2018
1 parent 055d27c commit fec14f8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,16 @@ - (void)setAsyncDelegate:(id<ASCollectionDelegate>)asyncDelegate
- (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
Expand Down
17 changes: 17 additions & 0 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ - (void)setAsyncDataSource:(id<ASTableDataSource>)asyncDataSource

_dataController.validationErrorSource = asyncDataSource;
super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
[self _asyncDelegateOrDataSourceDidChange];
}

- (id<ASTableDelegate>)asyncDelegate
Expand Down Expand Up @@ -506,6 +507,22 @@ - (void)setAsyncDelegate:(id<ASTableDelegate>)asyncDelegate
}

super.delegate = (id<UITableViewDelegate>)_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
Expand Down

0 comments on commit fec14f8

Please sign in to comment.