Merge pull request #1049 from hoppenichu/fix_donwloader_2

Make sure callbacksForURL won't be modified
This commit is contained in:
Olivier Poitrey 2015-02-25 17:04:13 -08:00
commit 9cc8269dcd
1 changed files with 2 additions and 2 deletions

View File

@ -138,7 +138,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
if (!sself) return; if (!sself) return;
__block NSArray *callbacksForURL; __block NSArray *callbacksForURL;
dispatch_sync(sself.barrierQueue, ^{ dispatch_sync(sself.barrierQueue, ^{
callbacksForURL = sself.URLCallbacks[url]; callbacksForURL = [sself.URLCallbacks[url] copy];
}); });
for (NSDictionary *callbacks in callbacksForURL) { for (NSDictionary *callbacks in callbacksForURL) {
SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
@ -150,7 +150,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
if (!sself) return; if (!sself) return;
__block NSArray *callbacksForURL; __block NSArray *callbacksForURL;
dispatch_barrier_sync(sself.barrierQueue, ^{ dispatch_barrier_sync(sself.barrierQueue, ^{
callbacksForURL = sself.URLCallbacks[url]; callbacksForURL = [sself.URLCallbacks[url] copy];
if (finished) { if (finished) {
[sself.URLCallbacks removeObjectForKey:url]; [sself.URLCallbacks removeObjectForKey:url];
} }