diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index 7dcd7107..825205be 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -44,11 +44,24 @@ void LottieLoader::run(unsigned tid) comp = parser.comp; } builder->build(comp); + + release(); } rebuild = false; } +void LottieLoader::release() +{ + if (copy) { + free((char*)content); + content = nullptr; + } + free(dirName); + dirName = nullptr; +} + + /************************************************************************/ /* External Class Implementation */ /************************************************************************/ @@ -63,8 +76,7 @@ LottieLoader::~LottieLoader() { done(); - if (copy) free((char*)content); - free(dirName); + release(); //TODO: correct position? delete(comp); @@ -76,6 +88,7 @@ bool LottieLoader::header() { //A single thread doesn't need to perform intensive tasks. if (TaskScheduler::threads() == 0) { + LoadModule::read(); run(0); if (comp) { w = static_cast(comp->w); @@ -87,7 +100,6 @@ bool LottieLoader::header() } else { return false; } - LoadModule::read(); } //Quickly validate the given Lottie file without parsing in order to get the animation info. @@ -254,11 +266,11 @@ bool LottieLoader::resize(Paint* paint, float w, float h) bool LottieLoader::read() { - if (!content || size == 0) return false; - //the loading has been already completed if (!LoadModule::read()) return true; + if (!content || size == 0) return false; + TaskScheduler::request(this); return true; diff --git a/src/loaders/lottie/tvgLottieLoader.h b/src/loaders/lottie/tvgLottieLoader.h index e42997a6..a752316a 100644 --- a/src/loaders/lottie/tvgLottieLoader.h +++ b/src/loaders/lottie/tvgLottieLoader.h @@ -77,6 +77,7 @@ private: void clear(); float startFrame(); void run(unsigned tid) override; + void release(); };