Return an error if the downloaded image has no pixels (fix #241)

This commit is contained in:
Olivier Poitrey 2012-12-10 15:25:45 +01:00
parent 21ff7bd6ff
commit 616d824dc7
1 changed files with 8 additions and 1 deletions

View File

@ -274,7 +274,14 @@
UIImage *image = [UIImage decodedImageWithImage:SDScaledImageForPath(self.request.URL.absoluteString, self.imageData)]; UIImage *image = [UIImage decodedImageWithImage:SDScaledImageForPath(self.request.URL.absoluteString, self.imageData)];
dispatch_async(dispatch_get_main_queue(), ^ dispatch_async(dispatch_get_main_queue(), ^
{ {
completionBlock(image, self.imageData, nil, YES); if (CGSizeEqualToSize(image.size, CGSizeZero))
{
completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Downloaded image has 0 pixels"}], YES);
}
else
{
completionBlock(image, self.imageData, nil, YES);
}
self.completionBlock = nil; self.completionBlock = nil;
[self done]; [self done];
}); });