Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inc/rlottie.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class RLOTTIE_API Animation {
* @internal
*/
static std::unique_ptr<Animation>
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.
Expand Down
5 changes: 3 additions & 2 deletions src/lottie/lottieloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,16 @@ std::shared_ptr<model::Composition> 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;
}

auto obj = internal::model::parse(const_cast<char *>(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;
}
Expand Down