summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyle.mm
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-11-14 15:50:33 -0800
committerGitHub <noreply@github.com>2016-11-14 15:50:33 -0800
commit1c9d314236736bf47e33fb95d2b457a5650fc519 (patch)
tree48b610e5bc18be13de161707488d1cb43b950c9d /platform/darwin/src/MGLStyle.mm
parent56c2272b7dc261f988c70e0f8cb90ff853932011 (diff)
downloadqtlocation-mapboxgl-1c9d314236736bf47e33fb95d2b457a5650fc519.tar.gz
[ios, macos] Take back source and layer ownership on removal (#7048)
If a source or layer is removed from the style, recapture the unique pointer ownership. This makes it safe to add back sources and layers after they have been removed.
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r--platform/darwin/src/MGLStyle.mm9
1 files changed, 2 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index d59194725b..7e67273a38 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -168,7 +168,7 @@ static NSURL *MGLStyleURL_emerald;
- (void)removeLayer:(MGLStyleLayer *)layer
{
- self.mapView.mbglMap->removeLayer(layer.identifier.UTF8String);
+ [layer removeFromMapView:self.mapView];
}
- (void)addLayer:(MGLStyleLayer *)layer
@@ -209,12 +209,7 @@ static NSURL *MGLStyleURL_emerald;
- (void)removeSource:(MGLSource *)source
{
- self.mapView.mbglMap->removeSource(source.identifier.UTF8String);
-
- // Once a mbgl source is removed from the map, ownership does not return
- // to the MGL source. Therefore, the rawSource pointer is set to NULL
- // so that the implementation of MGL source can avoid using it again.
- source.rawSource = NULL;
+ [source removeFromMapView:self.mapView];
}
- (NS_ARRAY_OF(NSString *) *)styleClasses