Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #311 from sebreh/master

Detect cancelled parent operation in download operation callback
  • Loading branch information...
commit 95337c47e91c40bb2db808e1b0ffc03a9312bd83 2 parents 05dd3f4 + d57b92c
Olivier Poitrey authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 SDWebImage/SDWebImageManager.m
7 SDWebImage/SDWebImageManager.m
View
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.