Bug 423802 - SVG file opens empty if defs structure element is not before structure element that references it.
Summary: SVG file opens empty if defs structure element is not before structure elemen...
Status: ASSIGNED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 4.2.9
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-02 17:06 UTC by steampoweredtaco
Modified: 2021-09-20 12:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Simple svg that reproduces the issue (1.38 KB, image/svg+xml)
2020-07-02 17:06 UTC, steampoweredtaco
Details
This file is a working version of repoBroken where the def and g elements are swapped (1.38 KB, image/svg+xml)
2020-07-02 17:08 UTC, steampoweredtaco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description steampoweredtaco 2020-07-02 17:06:51 UTC
Created attachment 129847 [details]
Simple svg that reproduces the issue

SUMMARY
Loading an SVG file that has a <defs> structure statement after another same level structure element, such as <g>, results in a broken import. Funny enough, the preview of recently open files will show the image just fine.

These files work in Inkscape and the newest browsers just fine.

Via the SVG spec these structure elements may be defined in any order at the same level which is typical of most xml schema and specs based off them.  The Krita parser probably needs to do two separate passes of the DOM to work correctly.

STEPS TO REPRODUCE
1. Open this fairly minimal reproduction 'repoBroken.svg' in Krita

OBSERVED RESULT
Notice no image is visible

EXPECTED RESULT
An image of two eye like shapes are visible.

SOFTWARE/OS VERSIONS
Windows: 10 64bit
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: Not sure

ADDITIONAL INFORMATION
If you edit the repoBroken.svg and move the <def> element above <g>, save, then open in Krita the expected result of an image of two eye like objects show up.

Attached is repoBroken.svg.
Comment 1 steampoweredtaco 2020-07-02 17:08:34 UTC
Created attachment 129848 [details]
This file is a working version of repoBroken where the def and g elements are swapped

repoBroken.svg is the broken version and repoWorking.svg is the version where I moved the <defs /> element above the <g /> element on the same level that does load in Krita.
Comment 2 Halla Rempt 2020-07-03 08:39:46 UTC
The preview is handled by Qt's svg support, while loading the file is done with our own svg parser. Thanks for the test file, I can reproduce the issue.