diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-12-06 11:48:36 +0100 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2016-12-13 10:03:05 -0800 |
commit | d3895b47efc28aa63b941de4341c4cb6fd6fb477 (patch) | |
tree | 785d499889b4d7439f30948296b76ac40a2462d0 /platform/darwin/src/MGLStyle.mm | |
parent | bb6973ae90d91134de168dc75f0d51e3e28c8ae4 (diff) | |
download | qtlocation-mapboxgl-d3895b47efc28aa63b941de4341c4cb6fd6fb477.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 c84782dba9..1e60b956c7 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -287,10 +287,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 belowLayer:nil]; + try { + [styleLayer addToMapView:self.mapView belowLayer:nil]; + } 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()]; + } } } @@ -374,7 +382,11 @@ static NSURL *MGLStyleURL_emerald; layer]; } [self willChangeValueForKey:@"layers"]; - [layer addToMapView:self.mapView belowLayer:nil]; + try { + [layer addToMapView:self.mapView belowLayer:nil]; + } catch (std::runtime_error & err) { + [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()]; + } [self didChangeValueForKey:@"layers"]; } @@ -399,7 +411,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"]; } @@ -437,10 +453,18 @@ static NSURL *MGLStyleURL_emerald; @"Make sure sibling was obtained using -[MGLStyle layerWithIdentifier:].", sibling]; } else if (index + 1 == layers.size()) { - [layer addToMapView:self.mapView belowLayer:nil]; + try { + [layer addToMapView:self.mapView belowLayer:nil]; + } 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"]; } |