diff options
author | Justin R. Miller <incanus@users.noreply.github.com> | 2016-09-21 10:59:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 10:59:45 -0700 |
commit | 2bde64fcb38ba6309ae32fbdac11d3a7575593c9 (patch) | |
tree | ac95804340a55d4821d8e8c81d87eb548df1dfb9 | |
parent | f4ba92af1f78a8819f99ba1f395785a7fe1a75e7 (diff) | |
download | qtlocation-mapboxgl-2bde64fcb38ba6309ae32fbdac11d3a7575593c9.tar.gz |
[ios] fix #6361: source query nullability & return nil for unfound results (#6408)
Also removes some dead code in MGLStyle.mm.
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 14 |
2 files changed, 5 insertions, 11 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index bc4c32da91..585d15c08c 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -187,7 +187,7 @@ static const NSInteger MGLStyleDefaultVersion = 9; @return source An instance of an `MGLSource` subclass. */ -- (MGLSource *)sourceWithIdentifier:(NSString *)identifier; +- (nullable MGLSource *)sourceWithIdentifier:(NSString *)identifier; /** Adds a new layer on top of existing layers. diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index c785ef7b62..79d7d7e0f6 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -92,19 +92,11 @@ static NSURL *MGLStyleURL_emerald; return @(self.mapView.mbglMap->getStyleName().c_str()); } -- (mbgl::style::Layer *)mbglLayerWithIdentifier:(NSString *)identifier -{ - return self.mapView.mbglMap->getLayer(identifier.UTF8String); -} - -- (mbgl::style::Source *)mbglSourceWithIdentifier:(NSString *)identifier -{ - return self.mapView.mbglMap->getSource(identifier.UTF8String); -} - - (id <MGLStyleLayer>)layerWithIdentifier:(NSString *)identifier { auto layer = self.mapView.mbglMap->getLayer(identifier.UTF8String); + + if (!layer) return nil; Class clazz = [self classFromLayer:layer]; @@ -119,6 +111,8 @@ static NSURL *MGLStyleURL_emerald; - (MGLSource *)sourceWithIdentifier:(NSString *)identifier { auto s = self.mapView.mbglMap->getSource(identifier.UTF8String); + + if (!s) return nil; Class clazz = [self classFromSource:s]; |