Skip to content

Commit 28109c4

Browse files
committed
Fixed SDWebImageCombinedOperation cancel crash (#798 #809)
1 parent c8df858 commit 28109c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SDWebImage/SDWebImageManager.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,13 @@ - (BOOL)isRunning {
298298
@implementation SDWebImageCombinedOperation
299299

300300
- (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock {
301+
// check if the operation is already cancelled, then we just call the cancelBlock
301302
if (self.isCancelled) {
302-
if (cancelBlock) cancelBlock();
303-
}
304-
else {
303+
if (cancelBlock) {
304+
cancelBlock();
305+
}
306+
_cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes
307+
} else {
305308
_cancelBlock = [cancelBlock copy];
306309
}
307310
}

0 commit comments

Comments
 (0)