Comment 4 for bug 1318657

Revision history for this message
David Mathog (mathog) wrote :

I will not have time to get back to this for a week. I'm posting what I have in case somebody else wants to have a look in the meantime.

The attached patch (may be applied to rev 13372) does NOT fix the issue, and I don't see why. The problem appeared to be that there was a missing case, it would only fix references for REF_STYLE and this was an instance of REF_HREF. So the appropriate code was moved in from another routine - and it did what it was supposed to, according to DEBUG statements in this patch, but it didn't make any difference with respect to the final bug. Strange.

The next attachment is the test case to use with that patch. To see the problem, do this:

1. start inkscape
2. file->open gradients-on-import-5.svg
3. file->new->default
4. select the little piece in the first window, copy it to the second
5. select the bigger piece in the first window, copy it to the second

The little piece uses linearGradient4100-8, and the bigger one is linearGradient4100, and these are identical. Since 4100-8 came in first all references to 4100 should be changed to 4100-8, and 4100 itself should be dropped. The DEBUG statements show that the xlink:href in lineargradient18282 is changed to use the former one. But by the time it gets to the point where the XML editor may be employed it is back to linearGradient4100. The other part of the code still worked, dropping 4100, so xlink:href to a nonexistent lineargradient, and BOOM.

I guess either the operation is working on a copy, and so is ignored, or something later, elsewhere, overwrites the change.

Here are the DEBUG statements that come out at step 5:
DEBUG importDefs 1
DEBUG prevent_id_clashes
DEBUG find_references xlink:href val #linearGradient4100
DEBUG change_def_references before find_references looking for linearGradient4100 to change to linearGradient4100-8
DEBUG find_references xlink:href val #linearGradient4100
DEBUG change_def_references after find_references
DEBUG change_def_references found refernces to linearGradient4100
DEBUG change_def_references for loop type 0
DEBUG change_def_references REF_HREF new_uri #linearGradient4100-8 of attribute xlink:href
DEBUG change_def_references changed element linearGradient18282 attribute xlink:href new value #linearGradient4100-8
DEBUG importDefs linearGradient18282 xlink:href is #linearGradient4100-8