diff options
Diffstat (limited to 'platform/darwin/src/MGLRasterSource.mm')
-rw-r--r-- | platform/darwin/src/MGLRasterSource.mm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLRasterSource.mm b/platform/darwin/src/MGLRasterSource.mm index 9f1d035994..c73a824ea8 100644 --- a/platform/darwin/src/MGLRasterSource.mm +++ b/platform/darwin/src/MGLRasterSource.mm @@ -82,12 +82,21 @@ static const CGFloat MGLRasterSourceRetinaTileSize = 512; } - (void)removeFromMapView:(MGLMapView *)mapView { + if (self.rawSource != mapView.mbglMap->getSource(self.identifier.UTF8String)) { + return; + } + auto removedSource = mapView.mbglMap->removeSource(self.identifier.UTF8String); - if (removedSource) { - _pendingSource = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::RasterSource> &>(removedSource)); - self.rawSource = _pendingSource.get(); + mbgl::style::RasterSource *source = dynamic_cast<mbgl::style::RasterSource *>(removedSource.get()); + if (!source) { + return; } + + removedSource.release(); + + _pendingSource = std::unique_ptr<mbgl::style::RasterSource>(source); + self.rawSource = _pendingSource.get(); } - (mbgl::style::RasterSource *)rawSource { |