summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-10-18 15:03:10 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-10-18 22:23:12 -0700
commit258acb6c487be5fc8c06094f134c60349c63d539 (patch)
tree26b2b0aabe1f3b911282aa06b09991cc121bbdc9
parent0b37408812131c91afd8b3accf1add709f5ca81c (diff)
downloadqtlocation-mapboxgl-258acb6c487be5fc8c06094f134c60349c63d539.tar.gz
[ios, macos] Raise correct style layer misuse exception (#6738)
Implement the layer property on MGLStyleLayer itself, where it’s declared, so that the check for an abstract style layer doesn’t itself raise an exception. The concrete style layer classes still declare their own layers as covariant properties, although those properties aren’t actually used anywhere. Cherry-picked from ce243043f5251bb6a7fabc90d8ca3162ade8a44f.
-rw-r--r--platform/darwin/src/MGLStyle.mm8
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm6
2 files changed, 10 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index f9f2e03d40..3964b47ad6 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -176,7 +176,7 @@ static NSURL *MGLStyleURL_emerald;
[NSException raise:NSInvalidArgumentException format:
@"The style layer %@ cannot be added to the style. "
@"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.",
- NSStringFromClass(self)];
+ layer];
}
self.mapView.mbglMap->addLayer(std::unique_ptr<mbgl::style::Layer>(layer.layer));
@@ -189,14 +189,14 @@ static NSURL *MGLStyleURL_emerald;
format:
@"The style layer %@ cannot be added to the style. "
@"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.",
- NSStringFromClass(layer)];
+ layer];
}
if (!otherLayer.layer) {
[NSException raise:NSInvalidArgumentException
format:
@"A style layer cannot be placed before %@ in the style. "
- @"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.",
- NSStringFromClass(otherLayer)];
+ @"Make sure otherLayer was obtained using -[MGLStyle layerWithIdentifier:].",
+ otherLayer];
}
const mbgl::optional<std::string> belowLayerId{otherLayer.identifier.UTF8String};
diff --git a/platform/darwin/src/MGLStyleLayer.mm b/platform/darwin/src/MGLStyleLayer.mm
index a2bb1fc2cf..293aa54f30 100644
--- a/platform/darwin/src/MGLStyleLayer.mm
+++ b/platform/darwin/src/MGLStyleLayer.mm
@@ -3,6 +3,12 @@
#include <mbgl/style/layer.hpp>
+@interface MGLStyleLayer ()
+
+@property (nonatomic) mbgl::style::Layer *layer;
+
+@end
+
@implementation MGLStyleLayer
- (instancetype)initWithIdentifier:(NSString *)identifier