lottie/slot: Fix incorrect image slot schema

Issue: #2964
This commit is contained in:
Jinny You 2024-11-18 18:49:59 +09:00 committed by Hermet Park
parent db800c8d45
commit 931d0748bb
2 changed files with 7 additions and 3 deletions

View file

@ -162,7 +162,7 @@ struct UserExample : tvgexam::Example
auto picture = slot3->picture(); auto picture = slot3->picture();
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample3.json"))) return false; if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample3.json"))) return false;
const char* slotJson = R"({"path_img":{"id":"image_0","w":200,"h":300,"u":"images/","p":"logo.png","e":0}})"; const char* slotJson = R"({"path_img":{"p":{"id":"image_0","w":200,"h":300,"u":"images/","p":"logo.png","e":0}}})";
if (!tvgexam::verify(slot3->override(slotJson))) return false; if (!tvgexam::verify(slot3->override(slotJson))) return false;
sizing(picture, 3); sizing(picture, 3);

View file

@ -958,6 +958,8 @@ void LottieParser::parseImage(LottieImage* image, const char* data, const char*
LottieObject* LottieParser::parseAsset() LottieObject* LottieParser::parseAsset()
{ {
enterObject();
LottieObject* obj = nullptr; LottieObject* obj = nullptr;
unsigned long id = 0; unsigned long id = 0;
@ -1019,7 +1021,6 @@ void LottieParser::parseAssets()
{ {
enterArray(); enterArray();
while (nextArrayValue()) { while (nextArrayValue()) {
enterObject();
auto asset = parseAsset(); auto asset = parseAsset();
if (asset) comp->assets.push(asset); if (asset) comp->assets.push(asset);
else TVGERR("LOTTIE", "Invalid Asset!"); else TVGERR("LOTTIE", "Invalid Asset!");
@ -1508,7 +1509,10 @@ bool LottieParser::apply(LottieSlot* slot, bool byDefault)
break; break;
} }
case LottieProperty::Type::Image: { case LottieProperty::Type::Image: {
obj = parseAsset(); while (auto key = nextObjectKey()) {
if (KEY_AS("p")) obj = parseAsset();
else skip(key);
}
context.parent = obj; context.parent = obj;
break; break;
} }