summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLVectorSource.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLVectorSource.mm')
-rw-r--r--platform/darwin/src/MGLVectorSource.mm15
1 files changed, 12 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm
index 840382913d..94511900c1 100644
--- a/platform/darwin/src/MGLVectorSource.mm
+++ b/platform/darwin/src/MGLVectorSource.mm
@@ -56,12 +56,21 @@
}
- (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::VectorSource> &>(removedSource));
- self.rawSource = _pendingSource.get();
+ mbgl::style::VectorSource *source = dynamic_cast<mbgl::style::VectorSource *>(removedSource.get());
+ if (!source) {
+ return;
}
+
+ removedSource.release();
+
+ _pendingSource = std::unique_ptr<mbgl::style::VectorSource>(source);
+ self.rawSource = _pendingSource.get();
}
- (mbgl::style::VectorSource *)rawSource {