diff options
Diffstat (limited to 'src/mbgl/style/style_impl.cpp')
-rw-r--r-- | src/mbgl/style/style_impl.cpp | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp index 5c9edc789f..760e2bc396 100644 --- a/src/mbgl/style/style_impl.cpp +++ b/src/mbgl/style/style_impl.cpp @@ -146,28 +146,13 @@ void Style::Impl::addSource(std::unique_ptr<Source> source) { sources.add(std::move(source)); } -struct SourceIdUsageEvaluator { - const std::string& sourceId; - - bool operator()(BackgroundLayer&) { return false; } - bool operator()(CustomLayer&) { return false; } - - template <class LayerType> - bool operator()(LayerType& layer) { - return layer.getSourceID() == sourceId; - } -}; - std::unique_ptr<Source> Style::Impl::removeSource(const std::string& id) { // Check if source is in use - SourceIdUsageEvaluator sourceIdEvaluator {id}; - auto layerIt = std::find_if(layers.begin(), layers.end(), [&](const auto& layer) { - return layer->accept(sourceIdEvaluator); - }); - - if (layerIt != layers.end()) { - Log::Warning(Event::General, "Source '%s' is in use, cannot remove", id.c_str()); - return nullptr; + for (const auto& layer: layers) { + if (layer->getSourceID() == id) { + Log::Warning(Event::General, "Source '%s' is in use, cannot remove", id.c_str()); + return nullptr; + } } std::unique_ptr<Source> source = sources.remove(id); |