mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix crash if batch update blocks are nil although method declaration allows nullable (#2599)
This commit is contained in:
committed by
Adlai Holler
parent
ae11fc755e
commit
44aa582ceb
@@ -653,7 +653,9 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
[_dataController beginUpdates];
|
||||
updates();
|
||||
if (updates) {
|
||||
updates();
|
||||
}
|
||||
[_dataController endUpdatesAnimated:animated completion:completion];
|
||||
}
|
||||
|
||||
|
||||
@@ -521,7 +521,9 @@ ASEnvironmentCollectionTableSetEnvironmentState(_environmentStateLock)
|
||||
- (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completion:(void (^)(BOOL))completion
|
||||
{
|
||||
[self.view beginUpdates];
|
||||
updates();
|
||||
if (updates) {
|
||||
updates();
|
||||
}
|
||||
[self.view endUpdatesAnimated:animated completion:completion];
|
||||
}
|
||||
|
||||
|
||||
@@ -798,4 +798,14 @@
|
||||
XCTAssertNotEqualObjects(oldHeader, newHeader);
|
||||
}
|
||||
|
||||
- (void)testThatNilBatchUpdatesCanBeSubmitted
|
||||
{
|
||||
__block ASCollectionViewTestController *testController = [[ASCollectionViewTestController alloc] initWithNibName:nil bundle:nil];
|
||||
__block ASCollectionNode *cn = testController.collectionNode;
|
||||
|
||||
// Passing nil blocks should not crash
|
||||
[cn performBatchUpdates:nil completion:nil];
|
||||
[cn performBatchAnimated:NO updates:nil completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -705,6 +705,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testThatNilBatchUpdatesCanBeSubmitted
|
||||
{
|
||||
ASTableNode *node = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
|
||||
|
||||
// Passing nil blocks should not crash
|
||||
[node performBatchUpdates:nil completion:nil];
|
||||
[node performBatchAnimated:NO updates:nil completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UITableView (Testing)
|
||||
|
||||
Reference in New Issue
Block a user