lottie: fixed a memory leak

A regression bug by efe7440fa0

To address this, removed the non-essential image pooling mechanism.

issue: https://github.com/thorvg/thorvg/issues/2959
This commit is contained in:
Hermet Park 2024-11-18 18:41:16 +09:00 committed by Hermet Park
parent 8107582c8b
commit db800c8d45
3 changed files with 12 additions and 7 deletions

View file

@ -980,7 +980,7 @@ void LottieBuilder::updateSolid(LottieLayer* layer)
void LottieBuilder::updateImage(LottieGroup* layer) void LottieBuilder::updateImage(LottieGroup* layer)
{ {
auto image = static_cast<LottieImage*>(layer->children.first()); auto image = static_cast<LottieImage*>(layer->children.first());
layer->scene->push(image->pooling(true)); layer->scene->push(image->picture);
} }

View file

@ -159,7 +159,10 @@ void LottieImage::prepare()
{ {
LottieObject::type = LottieObject::Image; LottieObject::type = LottieObject::Image;
auto picture = Picture::gen(); if (!picture) {
picture = Picture::gen();
PP(picture)->ref();
}
//force to load a picture on the same thread //force to load a picture on the same thread
TaskScheduler::async(false); TaskScheduler::async(false);
@ -170,10 +173,6 @@ void LottieImage::prepare()
TaskScheduler::async(true); TaskScheduler::async(true);
picture->size(data.width, data.height); picture->size(data.width, data.height);
PP(picture)->ref();
pooler.reset();
pooler.push(picture);
} }

View file

@ -672,9 +672,15 @@ struct LottieGradientStroke : LottieGradient, LottieStroke
}; };
struct LottieImage : LottieObject, LottieRenderPooler<tvg::Picture> struct LottieImage : LottieObject
{ {
LottieBitmap data; LottieBitmap data;
Picture* picture = nullptr;
~LottieImage()
{
if (PP(picture)->unref() == 0) delete(picture);
}
void override(LottieProperty* prop, bool byDefault = false) override void override(LottieProperty* prop, bool byDefault = false) override
{ {