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

Commit 30dba28

Browse files
committed
Remove _pendingContexts dictionary mutation during enumeration
1 parent dc7f67c commit 30dba28

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

AsyncDisplayKit/Details/ASCollectionDataController.mm

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ - (void)willReloadData
7373
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
7474
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
7575
}];
76+
7677
[_pendingContexts removeObjectForKey:kind];
7778
}
7879
}
@@ -101,6 +102,7 @@ - (void)willInsertSections:(NSIndexSet *)sections
101102
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
102103
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
103104
}];
105+
104106
[_pendingContexts removeObjectForKey:kind];
105107
}
106108
}
@@ -135,6 +137,7 @@ - (void)willReloadSections:(NSIndexSet *)sections
135137
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
136138
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
137139
}];
140+
138141
[_pendingContexts removeObjectForKey:kind];
139142
}
140143
}
@@ -172,7 +175,6 @@ - (void)willInsertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
172175
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
173176
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
174177
}];
175-
[_pendingContexts removeObjectForKey:kind];
176178
}];
177179
}
178180

@@ -201,7 +203,6 @@ - (void)willReloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
201203
[self batchLayoutNodesFromContexts:contexts ofKind:kind completion:^(NSArray<ASCellNode *> *nodes, NSArray<NSIndexPath *> *indexPaths) {
202204
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
203205
}];
204-
[_pendingContexts removeObjectForKey:kind];
205206
}];
206207
}
207208

@@ -216,12 +217,7 @@ - (void)_populateSupplementaryNodesOfKind:(NSString *)kind withMutableContexts:(
216217
NSUInteger rowCount = [self.collectionDataSource dataController:self supplementaryNodesOfKind:kind inSection:i];
217218
for (NSUInteger j = 0; j < rowCount; j++) {
218219
NSIndexPath *indexPath = [sectionIndexPath indexPathByAddingIndex:j];
219-
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts];
220-
221-
222-
223-
224-
220+
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts environmentTraitCollection:environmentTraitCollection];
225221
}
226222
}
227223
}
@@ -236,13 +232,16 @@ - (void)_populateSupplementaryNodesOfKind:(NSString *)kind withSections:(NSIndex
236232
NSIndexPath *sectionIndex = [[NSIndexPath alloc] initWithIndex:idx];
237233
for (NSUInteger i = 0; i < rowNum; i++) {
238234
NSIndexPath *indexPath = [sectionIndex indexPathByAddingIndex:i];
239-
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts];
235+
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts environmentTraitCollection:environmentTraitCollection];
240236
}
241237
}];
242238
}
243239

244240
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind atIndexPaths:(NSArray<NSIndexPath *> *)indexPaths mutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
245241
{
242+
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
243+
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
244+
246245
NSMutableIndexSet *sections = [NSMutableIndexSet indexSet];
247246
for (NSIndexPath *indexPath in indexPaths) {
248247
[sections addIndex:indexPath.section];
@@ -253,12 +252,12 @@ - (void)_populateSupplementaryNodesOfKind:(NSString *)kind atIndexPaths:(NSArray
253252
NSIndexPath *sectionIndex = [[NSIndexPath alloc] initWithIndex:idx];
254253
for (NSUInteger i = 0; i < rowNum; i++) {
255254
NSIndexPath *indexPath = [sectionIndex indexPathByAddingIndex:i];
256-
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts];
255+
[self _populateSupplementaryNodeOfKind:kind atIndexPath:indexPath mutableContexts:contexts environmentTraitCollection:environmentTraitCollection];
257256
}
258257
}];
259258
}
260259

261-
- (void)_populateSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath mutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
260+
- (void)_populateSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath mutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts environmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection
262261
{
263262
ASCellNodeBlock supplementaryCellBlock;
264263
if (_dataSourceImplementsSupplementaryNodeBlockOfKindAtIndexPath) {

0 commit comments

Comments
 (0)