1.
- GSList *sl; - sl = g_slist_copy ((GSList *) sp_selection_repr_list (selection)); - sl = g_slist_sort (sl, (GCompareFunc) sp_repr_compare_position); + const GSList *items = sp_selection_item_list (SP_DT_SELECTION (desktop));
I.e. you removed sorting the copied list of items. Why? The result is that the copied items now do not preserve z-order when pasted; they're pasted in the order in which they were selected, which is wrong (try it). And you cannot sort the list returned by sp_selectiion_{repr_}list, only a copy of it, which is what was done in the original code.
2. You only copy gradients applied to the fill, not to the stroke, so gradient-filled stroke is lost when copying between documents.
3. Here you check that the fill is either pattern or gradient, and then, without any further check, cast it into a gradient:
+ if (style && style->fill.type == SP_PAINT_TYPE_PAINTSERVER) { /* Object has pattern or gradient fill*/ + SPGradient *gradient = SP_GRADIENT (SP_OBJECT_STYLE_FILL_SERVER (items->data));
The result is quite predictable - it crashes when you try to copy an object with pattern fill. (Probably with bitmap fill also.)
4. When you paste copied objects with gradients within the same document, it still adds a copy of the gradient (with different id), although the pasted object still refers to the old gradient. This will lead to an unchecked growth of defs each time you do copy/paste. This should be prevented. E.g. check if the current defs contain an exact copy of the gradient you're about to add (not only same id but also same content), and if so, skip adding it.
5. Same thing when you copy an object with gradient to another document and that document already contains a different gradient with the same id. The result is that the pasted object uses that other document's gradient (different from its original gradient), while the correct gradient is added to the defs with a different id (and thus left unused). Fixing this is more complex: if the document you're pasting to contains a gradient with the same id but different content, you must change the id both of the gradient you're inserting to the defs _and_ the reference in the object style. The difficulty being, to check for identical content, you must check not only the content of the repr, but all other reprs it is linked to, and their links, and so on until the tree is exhausted.
_________________________________________________________________ MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI...