Merge pull request #2954 from dreampiggy/fix_rare_case_cancel_double_callback

Fix the rare case when call `SDWebImageDownloaderOperation.cancel`, the completion block may callback twice
This commit is contained in:
Kinarobin 2020-03-02 14:50:21 +08:00 committed by GitHub
commit f4548bba5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
if (self.isExecuting) self.executing = NO;
if (!self.isFinished) self.finished = YES;
}
} else {
// 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];
}