[ios, macos] Fix miscellaneous static analyzer warnings (#7670)
* [ios, macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLNetworkConfiguration, MGLRasterSource, and MGLShape. * [ios] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage. * [macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage and NSImage(MGLAdditions). * [ios, macos] Two pointer-equal images are object-equal by definition
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#import "MGLNetworkConfiguration.h"
|
||||
#import "NSProcessInfo+MGLAdditions.h"
|
||||
|
||||
@implementation MGLNetworkConfiguration
|
||||
|
||||
@@ -12,9 +11,6 @@
|
||||
}
|
||||
|
||||
+ (instancetype)sharedManager {
|
||||
if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
|
||||
return nil;
|
||||
}
|
||||
static dispatch_once_t onceToken;
|
||||
static MGLNetworkConfiguration *_sharedManager;
|
||||
void (^setupBlock)() = ^{
|
||||
|
||||
@@ -51,7 +51,7 @@ static const CGFloat MGLRasterSourceRetinaTileSize = 512;
|
||||
if (self = [super initWithIdentifier:identifier tileURLTemplates:tileURLTemplates options:options]) {
|
||||
mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, options);
|
||||
|
||||
uint16_t tileSize;
|
||||
uint16_t tileSize = MGLRasterSourceRetinaTileSize;
|
||||
if (NSNumber *tileSizeNumber = options[MGLTileSourceOptionTileSize]) {
|
||||
if (![tileSizeNumber isKindOfClass:[NSNumber class]]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
|
||||
@@ -94,9 +94,7 @@ bool operator==(const CLLocationCoordinate2D lhs, const CLLocationCoordinate2D r
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
NSUInteger hash;
|
||||
hash += _title.hash;
|
||||
hash += _subtitle.hash;
|
||||
NSUInteger hash = _title.hash + _subtitle.hash;
|
||||
#if !TARGET_OS_IPHONE
|
||||
hash += _toolTip.hash;
|
||||
#endif
|
||||
|
||||
@@ -55,17 +55,14 @@
|
||||
|
||||
MGLAnnotationImage *otherAnnotationImage = other;
|
||||
|
||||
return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier])
|
||||
return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier)
|
||||
|| [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier])
|
||||
&& _enabled == otherAnnotationImage.enabled
|
||||
&& ((!_image && !otherAnnotationImage.image) || [UIImagePNGRepresentation(_image) isEqualToData:UIImagePNGRepresentation(otherAnnotationImage.image)]);
|
||||
&& (_image == otherAnnotationImage.image || [UIImagePNGRepresentation(_image) isEqualToData:UIImagePNGRepresentation(otherAnnotationImage.image)]);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
NSUInteger hash;
|
||||
hash += [_reuseIdentifier hash];
|
||||
hash += _enabled;
|
||||
hash += [_image hash];
|
||||
return hash;
|
||||
return _reuseIdentifier.hash + _enabled + _image.hash;
|
||||
}
|
||||
|
||||
- (void)setImage:(UIImage *)image {
|
||||
|
||||
@@ -53,15 +53,11 @@
|
||||
return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier])
|
||||
&& _selectable == otherAnnotationImage.selectable
|
||||
&& ((!_cursor && !otherAnnotationImage.cursor) || [_cursor isEqual:otherAnnotationImage.cursor])
|
||||
&& ((!_image && !otherAnnotationImage.image) || [[_image TIFFRepresentation] isEqualToData:[otherAnnotationImage.image TIFFRepresentation]]);
|
||||
&& (_image == otherAnnotationImage.image || [[_image TIFFRepresentation] isEqualToData:[otherAnnotationImage.image TIFFRepresentation]]);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
NSUInteger hash;
|
||||
hash += [_reuseIdentifier hash];
|
||||
hash += _selectable;
|
||||
hash += [_image hash];
|
||||
return hash;
|
||||
return _reuseIdentifier.hash + @(_selectable).hash + _image.hash;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
std::string png = encodePNG(spriteImage->image);
|
||||
NSData *data = [[NSData alloc] initWithBytes:png.data() length:png.size()];
|
||||
NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:data];
|
||||
if ([self initWithSize:NSMakeSize(spriteImage->getWidth(), spriteImage->getHeight())]) {
|
||||
if (self = [self initWithSize:NSMakeSize(spriteImage->getWidth(), spriteImage->getHeight())]) {
|
||||
[self addRepresentation:rep];
|
||||
[self setTemplate:spriteImage->sdf];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user