Scour occasionaly produces empty defs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Low
|
jazzynico | ||
Scour |
Fix Released
|
Low
|
Unassigned | ||
scour (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
It's certainly a minor thing (the possible size reduction is 15 Bytes), but I find it unfortunate if I open a scoured file and the first thing I see is an empty defs.
It happens like this: I have a default svg template file for Inkscape which contains some standard gradients I may or may not be using while creating content. I may end up saving a file where none of them is referenced. Next I start scour.
Scour looks for empty defs', but my defs contains some gradients, so it leaves my defs untouched. Next, it checks for unreferenced gradients, and since all my gradients are unreferenced, it removes them all, as it should. Now it saves the file, with a defs element which is now empty.
I provided a patch which, hopefully, solves this.
Within scourString(), I swapped the order of the removal of empty defs and the call of removeUnreferen
I handled this by checking whether a child text node contains nothing but whitespace characters; a metadata element with nothing but whitespace as child nodes should be something we should be allowed to delete.
While I was at it, I also tried to slightly update the description of removeUnreferen
Finally, I added a new file for unittest with a defs element with nothing but unreferenced removable children and added a test to testscour.py to see whether it gets removed.
Related branches
tags: | added: patch |
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
Thanks Jan - this looks good to me, including the addition of the unit test, I assume all the other tests pass.
Since Louis has been much more involved with the project lately I'll let him review and merge it in to the trunk.
Thanks for your contribution!