From 6da746ac685f5f37b1b0b19e7085b4357482761b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sat, 16 Apr 2016 17:13:32 -0700 Subject: [PATCH] [osx] Fixed type mismatch and selector warnings Fixed some issues that were obscured by the old gyp-generated build settings. --- platform/osx/app/MapDocument.m | 10 +++++----- platform/osx/src/MGLMapView.mm | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m index 16d15c4ff..2c5930f00 100644 --- a/platform/osx/app/MapDocument.m +++ b/platform/osx/app/MapDocument.m @@ -480,13 +480,13 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { return YES; } if (menuItem.action == @selector(dropPin:)) { - BOOL isOverAnnotation = [self.mapView annotationAtPoint:_mouseLocationForMapViewContextMenu]; - menuItem.hidden = isOverAnnotation; + id annotationUnderCursor = [self.mapView annotationAtPoint:_mouseLocationForMapViewContextMenu]; + menuItem.hidden = annotationUnderCursor != nil; return YES; } if (menuItem.action == @selector(removePin:)) { - BOOL isOverAnnotation = [self.mapView annotationAtPoint:_mouseLocationForMapViewContextMenu]; - menuItem.hidden = !isOverAnnotation; + id annotationUnderCursor = [self.mapView annotationAtPoint:_mouseLocationForMapViewContextMenu]; + menuItem.hidden = annotationUnderCursor == nil; return YES; } if (menuItem.action == @selector(toggleTileBoundaries:)) { @@ -647,7 +647,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { [NSCursor dragCopyCursor], [NSCursor contextualMenuCursor], ]; - annotationImage.cursor = cursors[arc4random_uniform(cursors.count)]; + annotationImage.cursor = cursors[arc4random_uniform((uint32_t)cursors.count) % cursors.count]; } else { annotationImage.cursor = nil; } diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 597825143..c982e4fa5 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -481,6 +481,8 @@ public: _delegateHasFillColorsForShapeAnnotations = [_delegate respondsToSelector:@selector(mapView:fillColorForPolygonAnnotation:)]; _delegateHasLineWidthsForShapeAnnotations = [_delegate respondsToSelector:@selector(mapView:lineWidthForPolylineAnnotation:)]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" if ([self.delegate respondsToSelector:@selector(mapView:regionWillChangeAnimated:)]) { NSLog(@"-mapView:regionWillChangeAnimated: is not supported by the OS X SDK, but %@ implements it anyways. " @"Please implement -[%@ mapView:cameraWillChangeAnimated:] instead.", @@ -496,6 +498,7 @@ public: @"Please implement -[%@ mapView:cameraDidChangeAnimated:] instead.", NSStringFromClass([delegate class]), NSStringFromClass([delegate class])); } +#pragma clang diagnostic pop } #pragma mark Style @@ -2109,10 +2112,8 @@ public: } - (NSString *)view:(__unused NSView *)view stringForToolTip:(__unused NSToolTipTag)tag point:(__unused NSPoint)point userData:(void *)data { - if ((NSUInteger)data >= MGLAnnotationTagNotFound) { - return nil; - } - MGLAnnotationTag annotationTag = (NSUInteger)data; + NSAssert((NSUInteger)data < MGLAnnotationTagNotFound, @"Invalid annotation tag in tooltip rect user data."); + MGLAnnotationTag annotationTag = (MGLAnnotationTag)MIN((NSUInteger)data, MGLAnnotationTagNotFound); id annotation = [self annotationWithTag:annotationTag]; return annotation.toolTip; } @@ -2332,7 +2333,7 @@ public: mbgl::PremultipliedImage image { w, h }; MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get())); - const int stride = image.stride(); + const size_t stride = image.stride(); auto tmp = std::make_unique(stride); uint8_t *rgba = image.data.get(); for (int i = 0, j = h - 1; i < j; i++, j--) {