Merge pull request #1911 from disaabler/master

#1909: Crash on multiple concurrent downloads when accessing self.URLOperations dictionary
This commit is contained in:
Bogdan Poplauschi 2017-07-24 20:59:02 +03:00 committed by GitHub
commit add6fc8fa3
1 changed files with 7 additions and 5 deletions

View File

@ -230,11 +230,13 @@
__weak SDWebImageDownloaderOperation *woperation = operation;
operation.completionBlock = ^{
SDWebImageDownloaderOperation *soperation = woperation;
if (!soperation) return;
if (self.URLOperations[url] == soperation) {
[self.URLOperations removeObjectForKey:url];
};
dispatch_barrier_sync(self.barrierQueue, ^{
SDWebImageDownloaderOperation *soperation = woperation;
if (!soperation) return;
if (self.URLOperations[url] == soperation) {
[self.URLOperations removeObjectForKey:url];
};
});
};
}
id downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock];