Comment 4 for bug 166697

Revision history for this message
Craig Marshall (craig9-deactivatedaccount) wrote :

This was happening for me with the handles extension too (this extension draws handles where there are curves in the document, and does nothing if not). If you run the extension and there are no curves to draw handles for, inkscape still reads back in a (slightly) different document, and this triggers a save-requirement/dirty-flag inside inkscape.

A way around this (which I've implemented in the handles.py as a demonstration) is to set a simple dirty flag within the extension itself, and if there are no changes to the document, make a call to sys.exit(0), which bypasses the self.output() call in inkex.effect(), which rewrites the file. The 0 denotes a success exit from the program.

This seems to me a reasonable and simple workaround that could easily be done for each extension that can feasibly return an unchanged SVG document.

A better long-term solution would be to compare the input and output files for every extension within inkex.py (or in the inkscape core) and then set output to Null if there are no changes. Of course, the comparison is more difficult than running diff or testing if doc1 == doc2. Also, I couldn't get xmldiff to work here... Hence the simpler solution for now.

Apologies for the full file attachment, I don't yet have a working diff utility here.