Comment 14 for bug 1171109

Revision history for this message
insaner (insaner) wrote :

hi,
sorry for the great delay, I haven't really had much time to devote to this, and when I last had time I had to spend most of it just catching up with some of the changes to the code that affected this part in particular.

 let me share with you guys what I have been able to narrow down the problem to so far, perhaps someone can whip something up with this information.

the problem is caused by the fact that when you cut and then paste an object, you are changing a bunch of its references, and not all of them are properly updated, so that when you re-paste the object it isn't pointing to existing definitions, and when you alt + scroll, it tries to access these, which of course causes a segfault.

eg, you have a <linearGradient id="dark" ..> gradient, and your object makes use of this gradient via a
<linearGradient xlink:href="#dark" id="linearGradient7822" ...>
when you cut and paste the object, the xlink:href property is then changed to
<linearGradient xlink:href="#dark-6" id="linearGradient7837" ...>

the file in question is src/document.cpp, in method void SPDocument::importDefs(SPDocument *source) which calls
   prevent_id_clashes(source, this) from src/id-clash.cpp
which then calls
 change_clashing_ids(imported_doc, current_doc, imported_root, refmap,
                        &id_changes)
which is what changes these references.

I have tried a couple of things, but my lack of familiarity with how the code works has caused it to be a bit trickier for me than it would be for one of you more seasoned guys.

the fix is to create a check of some sort inside the

    if (id && current_doc->getObjectById(id)) {...}

of the change_clashing_ids() method, whereby it can check if a pasted object's definitions with clashing ids are identical to the ones that already exist in the document and have those references not be modified. This is where I haven't been able to advance.

let me know if this sounds simple enough for one of you guys to solve this week.. otherwise I will try a few things later this week to see what I can do to move us toward a solution.