[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:
Minh Nguyễn
2017-01-11 03:08:05 -08:00
committed by GitHub
parent b6cf87f5e7
commit 581fb3849d
6 changed files with 9 additions and 22 deletions

View File

@@ -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

View File

@@ -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];
}