Images can be downloaded in multiple threads. Therefore the call to self.failedURLs containsObject:url must be synchronized to avoid a collection mutation error.

This commit is contained in:
Charlie Savage 2013-05-07 02:31:59 -06:00
parent 990df9f828
commit 0426f07355
1 changed files with 7 additions and 1 deletions

View File

@ -83,7 +83,13 @@
__block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new; __block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new;
__weak SDWebImageCombinedOperation *weakOperation = operation; __weak SDWebImageCombinedOperation *weakOperation = operation;
if (!url || !completedBlock || (!(options & SDWebImageRetryFailed) && [self.failedURLs containsObject:url])) BOOL isFailedUrl = NO;
@synchronized(self.failedURLs)
{
isFailedUrl = [self.failedURLs containsObject:url];
}
if (!url || !completedBlock || (!(options & SDWebImageRetryFailed) && isFailedUrl))
{ {
if (completedBlock) completedBlock(nil, nil, SDImageCacheTypeNone, NO); if (completedBlock) completedBlock(nil, nil, SDImageCacheTypeNone, NO);
return operation; return operation;