lottie: fixed a compiler warning:

error: storing the address of local variable 'context' in '*this.LottieParser::context' [-Werror=dangling-pointer=]
 1255 |     this->context = &context;

issue: https://github.com/thorvg/thorvg/issues/2051
This commit is contained in:
Hermet Park 2024-03-14 12:55:31 +09:00
parent fc4f452362
commit b1ab52f89e
2 changed files with 4 additions and 10 deletions

View file

@ -252,7 +252,7 @@ void LottieParser::getValue(ColorStop& color)
{
if (peekType() == kArrayType) enterArray();
color.input = new Array<float>(context->gradient->colorStops.count);
color.input = new Array<float>(context.gradient->colorStops.count);
while (nextArrayValue()) color.input->push(getFloat());
}
@ -700,7 +700,7 @@ LottieRoundedCorner* LottieParser::parseRoundedCorner()
void LottieParser::parseGradient(LottieGradient* gradient, const char* key)
{
context->gradient = gradient;
context.gradient = gradient;
if (!strcmp(key, "t")) gradient->id = getInt();
else if (!strcmp(key, "o")) parseProperty<LottieProperty::Type::Opacity>(gradient->opacity, gradient);
@ -1132,7 +1132,7 @@ LottieLayer* LottieParser::parseLayer()
if (!layer) return nullptr;
layer->comp = comp;
context->layer = layer;
context.layer = layer;
auto ddd = false;
@ -1253,8 +1253,6 @@ bool LottieParser::parse(LottieSlot* slot)
{
enterObject();
LottieParser::Context context;
this->context = &context;
LottieObject* obj = nullptr; //slot object
switch (slot->type) {
@ -1303,10 +1301,6 @@ bool LottieParser::parse()
Array<LottieGlyph*> glyphes;
//assign parsing context
LottieParser::Context context;
this->context = &context;
while (auto key = nextObjectKey()) {
if (!strcmp(key, "v")) comp->version = getStringCopy();
else if (!strcmp(key, "fr")) comp->frameRate = getFloat();

View file

@ -110,7 +110,7 @@ private:
struct Context {
LottieLayer* layer = nullptr;
LottieGradient* gradient = nullptr;
} *context;
} context;
};
#endif //_TVG_LOTTIE_PARSER_H_