lottie: ++slot overriding

Keep trying overriding even if the given sid is invalid.

issue: https://github.com/thorvg/thorvg/issues/2969
This commit is contained in:
Hermet Park 2024-11-18 19:24:38 +09:00 committed by Hermet Park
parent a0f1c2d99d
commit 66d4bab696

View file

@ -295,8 +295,6 @@ bool LottieLoader::override(const char* slots, bool byDefault)
{
if (!ready() || comp->slots.count == 0) return false;
auto success = true;
//override slots
if (slots) {
//Copy the input data because the JSON parser will encode the data immediately.
@ -307,18 +305,21 @@ bool LottieLoader::override(const char* slots, bool byDefault)
parser.comp = comp;
auto idx = 0;
auto succeed = false;
while (auto sid = parser.sid(idx == 0)) {
auto applied = false;
for (auto s = comp->slots.begin(); s < comp->slots.end(); ++s) {
if (strcmp((*s)->sid, sid)) continue;
if (!parser.apply(*s, byDefault)) success = false;
if (parser.apply(*s, byDefault)) succeed = applied = true;
break;
}
if (!applied) parser.skip(sid);
++idx;
}
if (idx < 1) success = false;
free((char*)temp);
rebuild = overridden = success;
rebuild = succeed;
overridden |= succeed;
return rebuild;
//reset slots
} else if (overridden) {
for (auto s = comp->slots.begin(); s < comp->slots.end(); ++s) {
@ -327,7 +328,7 @@ bool LottieLoader::override(const char* slots, bool byDefault)
overridden = false;
rebuild = true;
}
return success;
return true;
}