diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-02-20 16:39:23 -0800 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2017-02-23 15:07:43 -0800 |
commit | 59820fb63d9970c1e2cda9cf950b819b79b1e7f7 (patch) | |
tree | 4b8a17e6b22373c16195037a0ea70249e979088b /platform/darwin/src/MGLStyleLayer.mm.ejs | |
parent | de1913e2234179b4a569444dc4219381694f12fe (diff) | |
download | qtlocation-mapboxgl-59820fb63d9970c1e2cda9cf950b819b79b1e7f7.tar.gz |
[ios, macos] Simplify implementation of layer removal from map view
This reverts a previous change that recreated the pending and raw
layer pointers if an identifier match caused a layer to be removed
but the removed layer was of a different type than the layer triggering
the removal
This refactors the pointer replacement to use a simpler solution that
returns early if the layer does not have a raw pointer loaded in the
mbgl map instance.
Diffstat (limited to 'platform/darwin/src/MGLStyleLayer.mm.ejs')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 7f44a7b4ae..24aff7fca8 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -150,17 +150,14 @@ namespace mbgl { - (void)removeFromMapView:(MGLMapView *)mapView { + if (self.rawLayer != mapView.mbglMap->getLayer(self.identifier.UTF8String)) { + return; + } + auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); if (!removedLayer) { return; } -<% if (type == 'background') { -%> - auto originalLayer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(self.identifier.UTF8String); -<% } else { -%> - auto originalLayer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(self.identifier.UTF8String, self.sourceIdentifier.UTF8String); -<% } -%> - _pendingLayer = std::move(originalLayer); - self.rawLayer = _pendingLayer.get(); mbgl::style::<%- camelize(type) %>Layer *layer = dynamic_cast<mbgl::style::<%- camelize(type) %>Layer *>(removedLayer.get()); if (!layer) { |