Calling completion callbacks in the main thread.
- made sure this is true even if the downloader is used on its own - SDWebImageManager doesn't need to perform a dispatch to the main thread any longer
This commit is contained in:
parent
9a3aff4851
commit
331053d26e
|
@ -237,7 +237,13 @@
|
|||
{
|
||||
UIImage *image = [UIImage decodedImageWithImage:SDScaledImageForPath(self.request.URL.absoluteString, [UIImage imageWithCGImage:partialImageRef])];
|
||||
CGImageRelease(partialImageRef);
|
||||
if (self.completedBlock) self.completedBlock(image, nil, nil, NO);
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
if (self.completedBlock)
|
||||
{
|
||||
self.completedBlock(image, nil, nil, NO);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,24 +99,21 @@
|
|||
if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
|
||||
__block id<SDWebImageOperation> subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
completedBlock(downloadedImage, error, SDImageCacheTypeNone, finished);
|
||||
|
||||
if (error)
|
||||
{
|
||||
completedBlock(downloadedImage, error, SDImageCacheTypeNone, finished);
|
||||
[self.failedURLs addObject:url];
|
||||
}
|
||||
else if (downloadedImage && finished)
|
||||
{
|
||||
[self.imageCache storeImage:downloadedImage imageData:data forKey:key toDisk:YES];
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
[self.failedURLs addObject:url];
|
||||
}
|
||||
else if (downloadedImage && finished)
|
||||
{
|
||||
[self.imageCache storeImage:downloadedImage imageData:data forKey:key toDisk:YES];
|
||||
}
|
||||
|
||||
if (finished)
|
||||
{
|
||||
[self.runningOperations removeObject:operation];
|
||||
}
|
||||
});
|
||||
if (finished)
|
||||
{
|
||||
[self.runningOperations removeObject:operation];
|
||||
}
|
||||
}];
|
||||
operation.cancelBlock = ^{[subOperation cancel];};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue