Resolve race condition.
While exceedingly unlikely, the old construct introduced potential race condition where it checked wself first, and assigned sself second. This now assigns sself first, and then checks that, which is the correct pattern, already used elsewhere in SDWebImage.
This commit is contained in:
parent
257da39e4d
commit
a46f6149e5
|
|
@ -127,8 +127,8 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
|
||||
options:options
|
||||
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
|
||||
if (!wself) return;
|
||||
SDWebImageDownloader *sself = wself;
|
||||
if (!sself) return;
|
||||
NSArray *callbacksForURL = [sself callbacksForURL:url];
|
||||
for (NSDictionary *callbacks in callbacksForURL) {
|
||||
SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
|
||||
|
|
@ -136,8 +136,8 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
}
|
||||
}
|
||||
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
|
||||
if (!wself) return;
|
||||
SDWebImageDownloader *sself = wself;
|
||||
if (!sself) return;
|
||||
NSArray *callbacksForURL = [sself callbacksForURL:url];
|
||||
if (finished) {
|
||||
[sself removeCallbacksForURL:url];
|
||||
|
|
@ -148,8 +148,8 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
}
|
||||
}
|
||||
cancelled:^{
|
||||
if (!wself) return;
|
||||
SDWebImageDownloader *sself = wself;
|
||||
if (!sself) return;
|
||||
[sself removeCallbacksForURL:url];
|
||||
}];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue