From b29bb2e2e1a3fe4642d1f7c123b1191c328bd285 Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Tue, 6 Nov 2012 18:24:57 +0100 Subject: [PATCH] Do not call completed block on categories for intermediate progressive images --- SDWebImage/MKAnnotationView+WebCache.m | 2 +- SDWebImage/UIButton+WebCache.m | 4 ++-- SDWebImage/UIImageView+WebCache.m | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SDWebImage/MKAnnotationView+WebCache.m b/SDWebImage/MKAnnotationView+WebCache.m index dc97d9ba..be49ecbf 100644 --- a/SDWebImage/MKAnnotationView+WebCache.m +++ b/SDWebImage/MKAnnotationView+WebCache.m @@ -49,7 +49,7 @@ static char operationKey; id operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, BOOL fromCache, BOOL finished) { if (image) self.image = image; - if (completedBlock) completedBlock(image, error, fromCache); + if (completedBlock && finished) completedBlock(image, error, fromCache); }]; objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } diff --git a/SDWebImage/UIButton+WebCache.m b/SDWebImage/UIButton+WebCache.m index 12dbc39e..1705d6d0 100644 --- a/SDWebImage/UIButton+WebCache.m +++ b/SDWebImage/UIButton+WebCache.m @@ -48,7 +48,7 @@ static char operationKey; id operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, BOOL fromCache, BOOL finished) { if (image) [self setImage:image forState:state]; - if (completedBlock) completedBlock(image, error, fromCache); + if (completedBlock && finished) completedBlock(image, error, fromCache); }]; objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @@ -90,7 +90,7 @@ static char operationKey; id operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, BOOL fromCache, BOOL finished) { if (image) [self setBackgroundImage:image forState:state]; - if (completedBlock) completedBlock(image, error, fromCache); + if (completedBlock && finished) completedBlock(image, error, fromCache); }]; objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } diff --git a/SDWebImage/UIImageView+WebCache.m b/SDWebImage/UIImageView+WebCache.m index 2d200488..b16862cc 100644 --- a/SDWebImage/UIImageView+WebCache.m +++ b/SDWebImage/UIImageView+WebCache.m @@ -58,7 +58,7 @@ static char operationKey; self.image = image; [self setNeedsLayout]; } - if (completedBlock) + if (completedBlock && finished) { completedBlock(image, error, fromCache); }