Skip to content

Commit

Permalink
fix(ios): fix a potential null pointer when waterfallview cell resuse
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Aug 1, 2022
1 parent cfb800d commit e50fc40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ios/sdk/component/waterfalllist/HippyReusableNodeCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ - (instancetype)init {
}

- (void)enqueueItemNode:(HippyVirtualNode *)node forIdentifier:(NSString *)identifier {
if (!node || !identifier) {
return;
}
NSMutableSet *set = _cache[identifier];
if (!set) {
set = [NSMutableSet set];
Expand Down
6 changes: 4 additions & 2 deletions ios/sdk/component/waterfalllist/HippyWaterfallView.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(
[hpCell.cellView removeFromSuperview];
HippyVirtualNode *cellNode = hpCell.node;
NSString *reuseIdentifier = [self reuseIdentifierForIndexPath:indexPath];
[_reusableNodeCache enqueueItemNode:cellNode forIdentifier:reuseIdentifier];
hpCell.node = nil;
if (cellNode && reuseIdentifier) {
[_reusableNodeCache enqueueItemNode:cellNode forIdentifier:reuseIdentifier];
hpCell.node = nil;
}
}

- (void)itemViewForCollectionViewCell:(UICollectionViewCell *)cell indexPath:(NSIndexPath *)indexPath {
Expand Down

0 comments on commit e50fc40

Please sign in to comment.