From 84979675100cb7f0677a6acfdd0302f59f8438eb Mon Sep 17 00:00:00 2001 From: Leon Styhre <leon@leonstyhre.com> Date: Sat, 12 Mar 2022 10:11:04 +0100 Subject: [PATCH] Disabled rlottie caching in debug mode so animations can be replaced on the fly. --- es-core/src/components/LottieAnimComponent.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/LottieAnimComponent.cpp b/es-core/src/components/LottieAnimComponent.cpp index 0cf973ce7..630367aab 100644 --- a/es-core/src/components/LottieAnimComponent.cpp +++ b/es-core/src/components/LottieAnimComponent.cpp @@ -105,8 +105,17 @@ void LottieAnimComponent::setAnimation(const std::string& path) ResourceData animData {ResourceManager::getInstance().getFileData(mPath)}; std::string cache; - mAnimation = rlottie::Animation::loadFromData( - std::string(reinterpret_cast<char*>(animData.ptr.get()), animData.length), cache); + // If in debug mode, then disable the rlottie caching so that animations can be replaced on + // the fly using Ctrl+r reloads. + if (Settings::getInstance()->getBool("Debug")) { + mAnimation = rlottie::Animation::loadFromData( + std::string(reinterpret_cast<char*>(animData.ptr.get()), animData.length), cache, "", + false); + } + else { + mAnimation = rlottie::Animation::loadFromData( + std::string(reinterpret_cast<char*>(animData.ptr.get()), animData.length), cache); + } if (mAnimation == nullptr) { LOG(LogError) << "Couldn't parse Lottie animation file \"" << mPath << "\"";