diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2016-11-15 10:05:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 10:05:35 -0800 |
commit | c78c97f346989524b84f90c4c72049f84d5346af (patch) | |
tree | 50dabf226bc7f439fda1071a91d1b2104eb19c60 | |
parent | 31206b4516e158991679d38a72443ed2eb6e5088 (diff) | |
download | qtlocation-mapboxgl-c78c97f346989524b84f90c4c72049f84d5346af.tar.gz |
[ios, macos] refs #7060: properly check removed layers & sources (#7062)
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index f1537f9496..e63e5e0aa8 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -168,6 +168,13 @@ static NSURL *MGLStyleURL_emerald; - (void)removeLayer:(MGLStyleLayer *)layer { + if (!layer.layer) { + [NSException raise:NSInvalidArgumentException format: + @"The style layer %@ cannot be removed from the style. " + @"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.", + layer]; + } + self.mapView.mbglMap->removeLayer(layer.identifier.UTF8String); } @@ -218,6 +225,13 @@ static NSURL *MGLStyleURL_emerald; - (void)removeSource:(MGLSource *)source { + if (!source.rawSource) { + [NSException raise:NSInvalidArgumentException format: + @"The source %@ cannot be removed from the style. " + @"Make sure the source was created as a member of a concrete subclass of MGLSource.", + source]; + } + self.mapView.mbglMap->removeSource(source.identifier.UTF8String); // Once a mbgl source is removed from the map, ownership does not return |