Authored by Olivier Poitrey

Fix disk image cache read not setting memory cache + ensure decodedImageWithImage never fail

@@ -191,16 +191,10 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week @@ -191,16 +191,10 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
191 191
192 dispatch_data_apply(dispatchedData, (dispatch_data_applier_t)^(dispatch_data_t region, size_t offset, const void *buffer, size_t size) 192 dispatch_data_apply(dispatchedData, (dispatch_data_applier_t)^(dispatch_data_t region, size_t offset, const void *buffer, size_t size)
193 { 193 {
194 - UIImage *diskImage = SDScaledImageForPath(key, [NSData dataWithBytes:buffer length:size]); 194 + UIImage *diskImage = [UIImage decodedImageWithImage:SDScaledImageForPath(key, [NSData dataWithBytes:buffer length:size])];
195 195
196 - if (image)  
197 - {  
198 - UIImage *decodedImage = [UIImage decodedImageWithImage:diskImage];  
199 - if (decodedImage) 196 + if (diskImage)
200 { 197 {
201 - diskImage = decodedImage;  
202 - }  
203 -  
204 [self.memCache setObject:diskImage forKey:key cost:image.size.height * image.size.width * image.scale]; 198 [self.memCache setObject:diskImage forKey:key cost:image.size.height * image.size.width * image.scale];
205 } 199 }
206 200
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 colorSpace, 35 colorSpace,
36 bitmapInfo); 36 bitmapInfo);
37 CGColorSpaceRelease(colorSpace); 37 CGColorSpaceRelease(colorSpace);
38 - if (!context) return nil; 38 + if (!context) return image;
39 39
40 CGRect rect = (CGRect){CGPointZero,{CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)}}; 40 CGRect rect = (CGRect){CGPointZero,{CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)}};
41 CGContextDrawImage(context, rect, imageRef); 41 CGContextDrawImage(context, rect, imageRef);