From 4696a8dda03dc332c72bd7bd4cdafab12308bba9 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 16 Nov 2018 15:09:51 -0500 Subject: Only set `_pendingSource` & clear `_mapView` if the source was removed. --- platform/darwin/src/MGLSource.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm index 3ec82ff36e..3403868d84 100644 --- a/platform/darwin/src/MGLSource.mm +++ b/platform/darwin/src/MGLSource.mm @@ -62,11 +62,13 @@ BOOL removed = NO; if (self.rawSource == mapView.style.rawStyle->getSource(self.identifier.UTF8String)) { - _pendingSource = mapView.style.rawStyle->removeSource(self.identifier.UTF8String); - _mapView = nil; - if (_pendingSource) { + auto removedSource = mapView.style.rawStyle->removeSource(self.identifier.UTF8String); + + if (removedSource) { removed = YES; + _pendingSource = std::move(removedSource); + _mapView = nil; } else if (outError) { NSString *format = NSLocalizedStringWithDefaultValue(@"REMOVE_SRC_FAIL_IN_USE_FMT", nil, nil, @"Source '%@' is in use, cannot remove.", @"User-friendly error description"); NSString *localizedDescription = [NSString stringWithFormat:format, self.identifier]; -- cgit v1.2.1