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
parent 88098f547f
commit a989dc9a7d
3 changed files with 12 additions and 7 deletions

View file

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

View file

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

View file

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