Fix the rare case when call `SDWebImageDownloaderOperation.cancel`, the completion block will callback twice

This commit is contained in:
DreamPiggy 2020-03-02 13:06:09 +08:00
parent eea85faaa5
commit 692f01b84b
1 changed files with 3 additions and 2 deletions

View File

@ -245,9 +245,10 @@ typedef NSMutableDictionary<NSString *, id> SDCallbacksDictionary;
// maintain the isFinished and isExecuting flags. // maintain the isFinished and isExecuting flags.
if (self.isExecuting) self.executing = NO; if (self.isExecuting) self.executing = NO;
if (!self.isFinished) self.finished = YES; if (!self.isFinished) self.finished = YES;
} } else {
// Operation cancelled by user during sending the request // Operation cancelled by user during sending the request
[self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCancelled userInfo:@{NSLocalizedDescriptionKey : @"Operation cancelled by user during sending the request"}]]; [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCancelled userInfo:@{NSLocalizedDescriptionKey : @"Operation cancelled by user during sending the request"}]];
}
[self reset]; [self reset];
} }