diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-12-06 11:48:36 +0100 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2016-12-12 09:05:23 -0500 |
commit | e9f101a52f626744991ee73c3ced9c48bc013a51 (patch) | |
tree | 2e2e36e3db3a58d5f81366bc12ce539189817044 /platform/darwin/src/MGLStyle.mm | |
parent | a32e62cb0f3a6d9654712ab93380b15db7b337aa (diff) | |
download | qtlocation-mapboxgl-e9f101a52f626744991ee73c3ced9c48bc013a51.tar.gz |
[ios, macos] handle duplicate layer error
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 6116f4df28..7d7ca73a58 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -271,10 +271,18 @@ static NSURL *MGLStyleURL_emerald; [NSException raise:NSRangeException format:@"Cannot insert style layer at out-of-bounds index %lu.", (unsigned long)index]; } else if (index == 0) { - [styleLayer addToMapView:self.mapView]; + try { + [styleLayer addToMapView:self.mapView]; + } catch (const std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } } else { - MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(layers.size() - index)]; - [styleLayer addToMapView:self.mapView belowLayer:sibling]; + try { + MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(layers.size() - index)]; + [styleLayer addToMapView:self.mapView belowLayer:sibling]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } } } @@ -350,7 +358,11 @@ static NSURL *MGLStyleURL_emerald; layer]; } [self willChangeValueForKey:@"layers"]; - [layer addToMapView:self.mapView]; + try { + [layer addToMapView:self.mapView]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } [self didChangeValueForKey:@"layers"]; } @@ -375,7 +387,11 @@ static NSURL *MGLStyleURL_emerald; sibling]; } [self willChangeValueForKey:@"layers"]; - [layer addToMapView:self.mapView belowLayer:sibling]; + try { + [layer addToMapView:self.mapView belowLayer:sibling]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } [self didChangeValueForKey:@"layers"]; } @@ -413,10 +429,18 @@ static NSURL *MGLStyleURL_emerald; @"Make sure sibling was obtained using -[MGLStyle layerWithIdentifier:].", sibling]; } else if (index + 1 == layers.size()) { - [layer addToMapView:self.mapView]; + try { + [layer addToMapView:self.mapView]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } } else { MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(index + 1)]; - [layer addToMapView:self.mapView belowLayer:sibling]; + try { + [layer addToMapView:self.mapView belowLayer:sibling]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } } [self didChangeValueForKey:@"layers"]; } |