summaryrefslogtreecommitdiff
path: root/src/mbgl/map/map.cpp
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-11-11 14:40:04 -0800
committerGitHub <noreply@github.com>2016-11-11 14:40:04 -0800
commitedf40bb6d9f0ee3731f39de597ce9a167571ea5b (patch)
treeb0a310487d4c3f53dde0b554ff16f1b1cacee9fe /src/mbgl/map/map.cpp
parent39b0bc0a402248e29791f93aeab5a6234bf80862 (diff)
downloadqtlocation-mapboxgl-edf40bb6d9f0ee3731f39de597ce9a167571ea5b.tar.gz
[core] Return source and layer ownership (#7014)
When a source or layer is removed transfer ownership back to the caller so it can (optionally) take it. Preserve the behavior that removing a CustomLayer triggers deinitialization. Deinitialize all custom layers when a style is destroyed in case those layers are not explicitly removed.
Diffstat (limited to 'src/mbgl/map/map.cpp')
-rw-r--r--src/mbgl/map/map.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 57845080f4..0c3e395e8a 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -851,11 +851,12 @@ void Map::addSource(std::unique_ptr<style::Source> source) {
}
}
-void Map::removeSource(const std::string& sourceID) {
+std::unique_ptr<Source> Map::removeSource(const std::string& sourceID) {
if (impl->style) {
impl->styleMutated = true;
- impl->style->removeSource(sourceID);
+ return impl->style->removeSource(sourceID);
}
+ return nullptr;
}
style::Layer* Map::getLayer(const std::string& layerID) {
@@ -880,18 +881,20 @@ void Map::addLayer(std::unique_ptr<Layer> layer, const optional<std::string>& be
impl->backend.deactivate();
}
-void Map::removeLayer(const std::string& id) {
+std::unique_ptr<Layer> Map::removeLayer(const std::string& id) {
if (!impl->style) {
- return;
+ return nullptr;
}
impl->styleMutated = true;
impl->backend.activate();
- impl->style->removeLayer(id);
+ auto removedLayer = impl->style->removeLayer(id);
impl->onUpdate(Update::Classes);
impl->backend.deactivate();
+
+ return removedLayer;
}
void Map::addImage(const std::string& name, std::unique_ptr<const SpriteImage> image) {