From 23f53187c1aa96a13332b8d3beaf91b99f49d0d6 Mon Sep 17 00:00:00 2001 From: knutux Date: Tue, 21 Mar 2006 07:22:28 +0000 Subject: [PATCH] Fixes to unmasking: - Fixed crash if unmask/unclip is used on unmasked object - Restoring mask/clippath object even if it is still referenced - Adding restored mask objects to selected item list --- src/selection-chemistry.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 91686d277..ba0d89850 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2385,8 +2385,9 @@ void sp_selection_unset_mask(bool apply_clip_path) { } else { uri_ref = item->mask_ref; } - - if (NULL != uri_ref && referenced_objects.end() == referenced_objects.find(uri_ref->getObject())) { + + // collect distinct mask object + if (NULL != uri_ref && NULL != uri_ref->getObject() && referenced_objects.end() == referenced_objects.find(uri_ref->getObject())) { referenced_objects.insert(uri_ref->getObject()); } } @@ -2394,23 +2395,26 @@ void sp_selection_unset_mask(bool apply_clip_path) { SP_OBJECT_REPR(i->data)->setAttribute(attributeName, "none"); } + // restore mask objects into a document for ( std::set::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it); + GSList *items_to_move = NULL; + for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(); + items_to_move = g_slist_prepend (items_to_move, copy); + } + if (!obj->isReferenced()) { - GSList *items_to_move = NULL; - for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(); - items_to_move = g_slist_prepend (items_to_move, copy); - } - + // delete from defs if no other object references this mask obj->deleteObject(false); + } - for (GSList *i = items_to_move; NULL != i; i = i->next) { - desktop->currentLayer()->appendChildRepr((Inkscape::XML::Node *)i->data); - } - - g_slist_free (items_to_move); + for (GSList *i = items_to_move; NULL != i; i = i->next) { + desktop->currentLayer()->appendChildRepr((Inkscape::XML::Node *)i->data); + selection->add((Inkscape::XML::Node *)i->data); } + + g_slist_free (items_to_move); } sp_document_done (document); -- 2.30.2