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 "SDImageAPNGCoderInternal.h"
@interface SDAnimatedImageRep ()
@property (nonatomic, assign, readonly, nullable) CGImageSourceRef imageSource;
@interface SDAnimatedImageRep () {
CGImageSourceRef _imageSource;
}
@end
@ -31,7 +31,7 @@
- (instancetype)initWithData:(NSData *)data {
self = [super initWithData:data];
if (self) {
CGImageSourceRef imageSource = self.imageSource;
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef) data, NULL);
if (!imageSource) {
return self;
}
@ -43,6 +43,8 @@
if (!type) {
return self;
}
// Valid CGImageSource for Animated Image
_imageSource = imageSource;
if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) {
// GIF
// Do nothing because NSBitmapImageRep support it
@ -63,7 +65,7 @@
[super setProperty:property withValue:value];
if ([property isEqualToString:NSImageCurrentFrame]) {
// Access the image source
CGImageSourceRef imageSource = self.imageSource;
CGImageSourceRef imageSource = _imageSource;
if (!imageSource) {
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
#endif