Detect parent operation cancellation in download operation completion block

This commit is contained in:
Sebastian Rehnby 2013-02-26 12:08:55 +01:00
parent 05dd3f4815
commit d57b92cd0e
1 changed files with 6 additions and 1 deletions

View File

@ -76,6 +76,7 @@
}
__block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new;
__weak SDWebImageCombinedOperation *weakOperation = operation;
if (!url || !completedBlock || (!(options & SDWebImageRetryFailed) && [self.failedURLs containsObject:url]))
{
@ -108,7 +109,11 @@
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);