tvg_saver: fix the memory leak.

This commit is contained in:
Hermet Park 2021-09-24 11:58:48 +09:00
parent c8cc973888
commit 3ee6883f16

View file

@ -366,7 +366,10 @@ TvgBinCounter TvgSaver::serializeChild(const Paint* parent, const Paint* child,
TvgBinCounter TvgSaver::serializeScene(const Scene* scene, const Matrix* pTransform, const Matrix* cTransform) TvgBinCounter TvgSaver::serializeScene(const Scene* scene, const Matrix* pTransform, const Matrix* cTransform)
{ {
auto it = this->iterator(scene); auto it = this->iterator(scene);
if (it->count() == 0) return 0; if (it->count() == 0) {
delete(it);
return 0;
}
//Case - Only Child: Skip saving this scene. //Case - Only Child: Skip saving this scene.
if (it->count() == 1) { if (it->count() == 1) {
@ -381,7 +384,9 @@ TvgBinCounter TvgSaver::serializeScene(const Scene* scene, const Matrix* pTransf
//Case - Delegator Scene: This scene is just a delegator, we can skip this: //Case - Delegator Scene: This scene is just a delegator, we can skip this:
if (scene->composite(nullptr) == CompositeMethod::None && scene->opacity() == 255) { if (scene->composite(nullptr) == CompositeMethod::None && scene->opacity() == 255) {
return serializeChildren(it, cTransform, false); auto ret = serializeChildren(it, cTransform, false);
delete(it);
return ret;
} }
//Case - Serialize Scene & its children //Case - Serialize Scene & its children