From 29b5bc372de91cc9ef62b02d6c3117a4e24a7ff0 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 9 Nov 2023 14:43:22 +0900 Subject: [PATCH] lottie/loader: Corrected an issue with the return value when loading fails. Previously, Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) would return 'Success' even when the data is invalid. This issue only occurred when the number of threads is set to 0. --- src/loaders/lottie/tvgLottieLoader.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index 9d420583..60c5f7ef 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -66,10 +66,11 @@ void LottieLoader::run(unsigned tid) builder->update(comp, frameNo); //initial loading } else { - LottieParser parser(content, dirName); - if (!parser.parse()) return; - comp = parser.comp; - if (!comp) return; + if (!comp) { + LottieParser parser(content, dirName); + if (!parser.parse()) return; + comp = parser.comp; + } builder->build(comp); w = static_cast(comp->w); h = static_cast(comp->h); @@ -104,7 +105,12 @@ LottieLoader::~LottieLoader() bool LottieLoader::header() { //A single thread doesn't need to perform intensive tasks. - if (TaskScheduler::threads() == 0) return true; + if (TaskScheduler::threads() == 0) { + LottieParser parser(content, dirName); + if (!parser.parse()) return false; + comp = parser.comp; + return true; + } //Quickly validate the given Lottie file without parsing in order to get the animation info. auto startFrame = 0.0f;