[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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user