mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: fix text nodes issue
Since the text node wasn't pushed onto the loader's stack, closing the text node incorrectly caused an element to be popped from the stack (if one was present). This could result in elements that were supposed to have that element as a parent being rendered incorrectly or not being rendered at all. Now, the text node is correctly pushed onto the stack. @Issue: https://github.com/thorvg/thorvg/issues/2706
This commit is contained in:
parent
fa469f8bea
commit
0bcedd2f44
1 changed files with 4 additions and 6 deletions
|
@ -3288,6 +3288,7 @@ static void _svgLoaderParserXmlClose(SvgLoaderData* loader, const char* content,
|
|||
for (unsigned int i = 0; i < sizeof(graphicsTags) / sizeof(graphicsTags[0]); i++) {
|
||||
if (!strncmp(tagName, graphicsTags[i].tag, sz)) {
|
||||
loader->currentGraphicsNode = nullptr;
|
||||
if (!strncmp(tagName, "text", 4)) loader->openedTag = OpenedTagType::Other;
|
||||
loader->stack.pop();
|
||||
break;
|
||||
}
|
||||
|
@ -3361,11 +3362,9 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
node = method(loader, parent, attrs, attrsLength, simpleXmlParseAttributes);
|
||||
if (node && !empty) {
|
||||
if (!strcmp(tagName, "text")) loader->openedTag = OpenedTagType::Text;
|
||||
else {
|
||||
auto defs = _createDefsNode(loader, nullptr, nullptr, 0, nullptr);
|
||||
loader->stack.push(defs);
|
||||
loader->currentGraphicsNode = node;
|
||||
}
|
||||
auto defs = _createDefsNode(loader, nullptr, nullptr, 0, nullptr);
|
||||
loader->stack.push(defs);
|
||||
loader->currentGraphicsNode = node;
|
||||
}
|
||||
} else if ((gradientMethod = _findGradientFactory(tagName))) {
|
||||
SvgStyleGradient* gradient;
|
||||
|
@ -3403,7 +3402,6 @@ static void _svgLoaderParserText(SvgLoaderData* loader, const char* content, uns
|
|||
auto text = &loader->svgParse->node->node.text;
|
||||
if (text->text) free(text->text);
|
||||
text->text = strDuplicate(content, length);
|
||||
loader->openedTag = OpenedTagType::Other;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue