diff --git a/inc/rlottie.h b/inc/rlottie.h index 67565691..b527bf48 100644 --- a/inc/rlottie.h +++ b/inc/rlottie.h @@ -305,8 +305,8 @@ class RLOTTIE_API Animation { * @internal */ static std::unique_ptr - loadFromData(std::string jsonData, const std::string &key, - const std::string &resourcePath="", bool cachePolicy=true); + loadFromData(std::string jsonData, const std::string &key = std::string(), + const std::string &resourcePath = std::string(), bool cachePolicy=true); /** * @brief Constructs an animation object from JSON string data and update. diff --git a/src/lottie/lottieloader.cpp b/src/lottie/lottieloader.cpp index 8a52949e..68adf605 100644 --- a/src/lottie/lottieloader.cpp +++ b/src/lottie/lottieloader.cpp @@ -148,7 +148,7 @@ std::shared_ptr model::loadFromData( std::string jsonData, const std::string &key, std::string resourcePath, bool cachePolicy) { - if (cachePolicy) { + if (cachePolicy && !key.empty()) { auto obj = ModelCache::instance().find(key); if (obj) return obj; } @@ -156,7 +156,8 @@ std::shared_ptr model::loadFromData( auto obj = internal::model::parse(const_cast(jsonData.c_str()), std::move(resourcePath)); - if (obj && cachePolicy) ModelCache::instance().add(key, obj); + if (obj && cachePolicy && !key.empty()) + ModelCache::instance().add(key, obj); return obj; }