Permalink
Browse files

Detect parent operation cancellation in download operation completion…

… block
  • Loading branch information...
1 parent 05dd3f4 commit d57b92cd0e856551488eac2403ca52c9af75bf2a Sebastian Rehnby committed Feb 26, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 SDWebImage/SDWebImageManager.m
@@ -76,6 +76,7 @@ - (NSString *)cacheKeyForURL:(NSURL *)url
}
__block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new;
+ __weak SDWebImageCombinedOperation *weakOperation = operation;
if (!url || !completedBlock || (!(options & SDWebImageRetryFailed) && [self.failedURLs containsObject:url]))
{
@@ -108,7 +109,11 @@ - (NSString *)cacheKeyForURL:(NSURL *)url
if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished)
{
- if (error)
+ if (weakOperation.cancelled)
+ {
+ completedBlock(nil, nil, SDImageCacheTypeNone, finished);
+ }
+ else if (error)
{
completedBlock(nil, error, SDImageCacheTypeNone, finished);

0 comments on commit d57b92c

Please sign in to comment.