Deep Ungroup: error upon trying to ungroup this weird svg

Bug #1693578 reported by Hachmann
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Undecided
Unassigned

Bug Description

Trying to help a user to ungroup a strangely grouped SVG file in the forums [1], I got this error message:

Traceback from extension:

Traceback (most recent call last):
  File "ungroup_deep.py", line 281, in <module>
    effect.affect()
  File "/opt/inkscape_0.92.1/share/inkscape/extensions/inkex.py", line 283, in affect
    self.effect()
  File "ungroup_deep.py", line 274, in effect
    self._deep_ungroup(elem)
  File "ungroup_deep.py", line 259, in _deep_ungroup
    self._ungroup(node)
  File "ungroup_deep.py", line 203, in _ungroup
    self._merge_transform(c, node_transform)
  File "ungroup_deep.py", line 105, in _merge_transform
    simpletransform.formatTransform(this_transform))
  File "src/lxml/lxml.etree.pyx", line 1641, in lxml.etree.__ContentOnlyElement.set (src/lxml/lxml.etree.c:62503)
  File "src/lxml/lxml.etree.pyx", line 1637, in lxml.etree.__ContentOnlyElement._raiseImmutable (src/lxml/lxml.etree.c:62395)
TypeError: this element does not have children or attributes

[1] Forum discussion: http://www.inkscapeforum.com/viewtopic.php?f=5&t=32433
[2] Link to example file (have asked for permission to append):
https://www.dropbox.com/s/ncrudvnsra0dqet/Exp.SS.4.7.121-Layout%20with%20Overlays-Batch.svg?dl=0

Revision history for this message
Alvin Penner (apenner) wrote :

confirmed on Windows 10, Inkscape 0.92.1 r15371, using the extension "Arrange->Deep Ungroup".

apparently caused by the html style comments of the type
<!-- drawing style -->

attached is a reduced test case that shows the same crash

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Hachmann (marenhachmann) wrote :

Thank you, Alvin!

Revision history for this message
su_v (suv-lp) wrote :

Proposed patch to skip (valid) comments when iterating over children of etree elements.

tags: added: extensions-plugins
Revision history for this message
Hachmann (marenhachmann) wrote :

Thank you, V, works! (corrected my forum post, too)

Revision history for this message
su_v (suv-lp) wrote :

The proposed patch from comment #3 does drop (i.e. not preserve) any XML comments within the ungrouped groups (inkscape does that too, when ungrouping "manually"). I briefly investigated a different solution which preserves comments as such, but unfortunately, Inkscape (0.92.x) gets (temporarily) confused about the stack order when reloading a document returned from an extension where comments have been moved from inside a group to SVG Root (this can be reproduced independent of ungroup_deep.py). Reloading the file after saving though shows the expected result (and behavior).

While not really usable/applicable at the moment, I'm attaching that other diff too (for discussion maybe, or potentially for a future version of Inkscape which better handles reloading content with re-stacked XML comments). It only supports python2 (no 'basestring' in python3).

With regard to the original test case: 'Deep Ungroup' currently does not support preserving presentation attributes inherited from parent groups (as opposed to inline CSS style properties). This is not related to the bug reported/tracked here (failure due to attempting to process etree.Comment as etree.Element); and can be worked around by forcing an update of the drawing content (e.g. nudging the top-level group, which triggers Inkscape to rewrite presentation attributes as inline CSS style properties) before applying the extension. Those style properties defined on parent groups are then processed as expected by 'Deep Ungroup'.

Revision history for this message
su_v (suv-lp) wrote :

Deleting the attached diffs - I am revoking my pending patches provided in this bug tracker for issues with python-based extensions distributed with Inkscape.

Revision history for this message
Nathan Lee (nathan.lee) wrote :

Hi - thanks for the report. Still happening, but it's manually been migrated to gitlab at https://gitlab.com/inkscape/extensions/-/issues/405 as part of the bug migration!

Changed in inkscape:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.