Merge branch 'master' of https://github.com/rs/SDWebImage into 5.x
* 'master' of https://github.com/rs/SDWebImage: Update the spec file to define the dependency version for libwebp Bugfix for loopCount (#2155) Fix that 0 pixels error should be used when width OR height is zero but not AND Avoid user accidentally invalidates the session used in shared downloader Remove the extra memory warning notification for AutoPurgeCache
This commit is contained in:
commit
092e88e55f
|
@ -62,6 +62,6 @@ Pod::Spec.new do |s|
|
|||
'USER_HEADER_SEARCH_PATHS' => '$(inherited) $(SRCROOT)/libwebp/src'
|
||||
}
|
||||
webp.dependency 'SDWebImage/Core'
|
||||
webp.dependency 'libwebp'
|
||||
webp.dependency 'libwebp', '~> 0.5'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,31 +11,6 @@
|
|||
#import "NSImage+WebCache.h"
|
||||
#import "SDWebImageCodersManager.h"
|
||||
|
||||
// See https://github.com/rs/SDWebImage/pull/1141 for discussion
|
||||
@interface AutoPurgeCache : NSCache
|
||||
@end
|
||||
|
||||
@implementation AutoPurgeCache
|
||||
|
||||
- (nonnull instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
#if SD_UIKIT
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
#if SD_UIKIT
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||
#if SD_MAC
|
||||
return image.size.height * image.size.width;
|
||||
|
@ -96,7 +71,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
|||
_config = [[SDImageCacheConfig alloc] init];
|
||||
|
||||
// Init the memory cache
|
||||
_memCache = [[AutoPurgeCache alloc] init];
|
||||
_memCache = [[NSCache alloc] init];
|
||||
_memCache.name = fullNamespace;
|
||||
|
||||
// Init the disk cache
|
||||
|
|
|
@ -250,6 +250,7 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB
|
|||
* Invalidates the managed session, optionally canceling pending operations.
|
||||
* @note If you use custom downloader instead of the shared downloader, you need call this method when you do not use it to avoid memory leak
|
||||
* @param cancelPendingOperations Whether or not to cancel pending operations.
|
||||
* @note Calling this method on the shared downloader has no effect.
|
||||
*/
|
||||
- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations;
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@
|
|||
}
|
||||
|
||||
- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations {
|
||||
if (self == [SDWebImageDownloader sharedDownloader]) {
|
||||
return;
|
||||
}
|
||||
if (cancelPendingOperations) {
|
||||
[self.session invalidateAndCancel];
|
||||
} else {
|
||||
|
|
|
@ -419,7 +419,8 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
image = [[SDWebImageCodersManager sharedInstance] decompressedImageWithImage:image data:&imageData options:@{SDWebImageCoderScaleDownLargeImagesKey: @(shouldScaleDown)}];
|
||||
}
|
||||
}
|
||||
if (CGSizeEqualToSize(image.size, CGSizeZero)) {
|
||||
CGSize imageSize = image.size;
|
||||
if (imageSize.width == 0 || imageSize.height == 0) {
|
||||
[self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}]];
|
||||
} else {
|
||||
[self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES];
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
[frames addObject:frame];
|
||||
}
|
||||
|
||||
NSUInteger loopCount = 0;
|
||||
NSUInteger loopCount = 1;
|
||||
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
|
||||
NSDictionary *gifProperties = [imageProperties valueForKey:(__bridge_transfer NSString *)kCGImagePropertyGIFDictionary];
|
||||
if (gifProperties) {
|
||||
|
|
Loading…
Reference in New Issue