[Bug 717254] Re: Scour occasionaly produces empty defs

jazzynico 717254 at bugs.launchpad.net
Sat Feb 14 14:44:47 UTC 2015


** Changed in: inkscape
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to scour in Ubuntu.
https://bugs.launchpad.net/bugs/717254

Title:
  Scour occasionaly produces empty defs

Status in Inkscape: A Vector Drawing Tool:
  Fix Released
Status in Scour - Cleaning SVG Files:
  Fix Released
Status in scour package in Ubuntu:
  Fix Released

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 removeUnreferencedElements(), but that wasn't
  sufficient: the removal of empty defs is also the same code as the
  removal of empty metadata and the removal of empty groups. After
  successfully removing gradients, filters, pattern and symbols from my
  defs element, those removed elements left some text nodes behind which
  contain some whitespace. When checking for the presence of children,
  scour also checks for the presence of text node children, since it
  preserves metadata with (nothing but) text (it checks for the presence
  of child nodes of type 1, 3, 4 or 8, with 3 being the type of text
  nodes).

  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
  removeUnreferencedElements(), and deleted setting num=0 a second time
  halfway through the code, which, I think, shouldn't be there. Within
  scourString(), I deleted a variable elemsToRemove which doesn't do
  anything.

  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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/inkscape/+bug/717254/+subscriptions



More information about the foundations-bugs mailing list