Merge pull request #2745 from dreampiggy/fix_macOS_animated_API

Fix the SDAnimatedImageRep which use the deprecated API and cause compile issue on Xcode 11
This commit is contained in:
DreamPiggy 2019-06-05 16:58:24 +08:00 committed by GitHub
commit ba39cec210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 15 deletions

View File

@ -13,9 +13,9 @@
#import "SDImageGIFCoderInternal.h" #import "SDImageGIFCoderInternal.h"
#import "SDImageAPNGCoderInternal.h" #import "SDImageAPNGCoderInternal.h"
@interface SDAnimatedImageRep () @interface SDAnimatedImageRep () {
CGImageSourceRef _imageSource;
@property (nonatomic, assign, readonly, nullable) CGImageSourceRef imageSource; }
@end @end
@ -31,7 +31,7 @@
- (instancetype)initWithData:(NSData *)data { - (instancetype)initWithData:(NSData *)data {
self = [super initWithData:data]; self = [super initWithData:data];
if (self) { if (self) {
CGImageSourceRef imageSource = self.imageSource; CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef) data, NULL);
if (!imageSource) { if (!imageSource) {
return self; return self;
} }
@ -43,6 +43,8 @@
if (!type) { if (!type) {
return self; return self;
} }
// Valid CGImageSource for Animated Image
_imageSource = imageSource;
if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) { if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) {
// GIF // GIF
// Do nothing because NSBitmapImageRep support it // Do nothing because NSBitmapImageRep support it
@ -63,7 +65,7 @@
[super setProperty:property withValue:value]; [super setProperty:property withValue:value];
if ([property isEqualToString:NSImageCurrentFrame]) { if ([property isEqualToString:NSImageCurrentFrame]) {
// Access the image source // Access the image source
CGImageSourceRef imageSource = self.imageSource; CGImageSourceRef imageSource = _imageSource;
if (!imageSource) { if (!imageSource) {
return; return;
} }
@ -89,16 +91,6 @@
} }
} }
- (CGImageSourceRef)imageSource {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if (_tiffData) {
return (__bridge CGImageSourceRef)(_tiffData);
}
#pragma GCC diagnostic pop
return NULL;
}
@end @end
#endif #endif