use @syncrhonized (self) in the whole checkDone method, no longer allows something that add new handlers during checkDone

This commit is contained in:
马遥 2023-07-28 14:56:28 +08:00
parent 1ee0dbacea
commit 2d73e96fdf
1 changed files with 10 additions and 11 deletions

View File

@ -343,10 +343,8 @@
// if all tokens have been processed call [self done].
- (void)checkDoneWithImageData:(NSData *)imageData
finishedTokens:(NSArray<SDWebImageDownloaderOperationToken *> *)finishedTokens {
NSMutableArray<SDWebImageDownloaderOperationToken *> *tokens;
@synchronized (self) {
tokens = [self.callbackTokens mutableCopy];
}
NSMutableArray<SDWebImageDownloaderOperationToken *> *tokens = [self.callbackTokens mutableCopy];
[finishedTokens enumerateObjectsUsingBlock:^(SDWebImageDownloaderOperationToken * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[tokens removeObjectIdenticalTo:obj];
}];
@ -357,6 +355,7 @@
[self startCoderOperationWithImageData:imageData pendingTokens:tokens finishedTokens:finishedTokens];
}
}
}
- (void)startCoderOperationWithImageData:(NSData *)imageData
pendingTokens:(NSArray<SDWebImageDownloaderOperationToken *> *)pendingTokens