diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-11-11 14:40:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-11 14:40:04 -0800 |
commit | edf40bb6d9f0ee3731f39de597ce9a167571ea5b (patch) | |
tree | b0a310487d4c3f53dde0b554ff16f1b1cacee9fe /src/mbgl/style/layers/custom_layer_impl.cpp | |
parent | 39b0bc0a402248e29791f93aeab5a6234bf80862 (diff) | |
download | qtlocation-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/style/layers/custom_layer_impl.cpp')
-rw-r--r-- | src/mbgl/style/layers/custom_layer_impl.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp index 124d6b0ce9..1126d57552 100644 --- a/src/mbgl/style/layers/custom_layer_impl.cpp +++ b/src/mbgl/style/layers/custom_layer_impl.cpp @@ -23,11 +23,7 @@ CustomLayer::Impl::Impl(const CustomLayer::Impl& other) // Don't copy anything else. } -CustomLayer::Impl::~Impl() { - if (deinitializeFn) { - deinitializeFn(context); - } -} +CustomLayer::Impl::~Impl() = default; std::unique_ptr<Layer> CustomLayer::Impl::clone() const { return std::make_unique<CustomLayer>(*this); @@ -43,6 +39,12 @@ void CustomLayer::Impl::initialize() { initializeFn(context); } +void CustomLayer::Impl::deinitialize() { + if (deinitializeFn) { + deinitializeFn(context); + } +} + void CustomLayer::Impl::render(const TransformState& state) const { assert(renderFn); |