From 9ba7eae5f79161f75414ec25341ccf26417b0e94 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Sat, 24 Feb 2007 18:45:44 +0000 Subject: [PATCH] make selection_contains_both_clone_and_original reusable --- src/selection-chemistry.cpp | 42 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 541d04fff..cf16aba60 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1333,6 +1333,30 @@ void sp_selection_to_prev_layer () g_slist_free ((GSList *) items); } +bool +selection_contains_both_clone_and_original (Inkscape::Selection *selection) +{ + bool clone_with_original = false; + for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { + SPItem *item = SP_ITEM(l->data); + bool is_use = SP_IS_USE(item); + SPItem *item_use = item; + SPItem *item_use_first = item; + while (is_use && item_use && !clone_with_original) + { + item_use = sp_use_get_original (SP_USE(item_use)); + clone_with_original |= selection->includes(item_use); + if (item_use == item_use_first) + break; + is_use = SP_IS_USE(item_use); + } + if (clone_with_original) + break; + } + return clone_with_original; +} + + /** Apply matrix to the selection. \a set_i2d is normally true, which means objects are in the original transform, synced with their reprs, and need to jump to the new transform in one go. A value of set_i2d==false is only used by seltrans when it's dragging objects live (not outlines); in @@ -2578,23 +2602,7 @@ sp_selection_set_mask(bool apply_clip_path, bool apply_to_layer) // FIXME: temporary patch to prevent crash! // Remove this when bboxes are fixed to not blow up on an item clipped/masked with its own clone - bool clone_with_original = false; - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = SP_ITEM(l->data); - bool is_use = SP_IS_USE(item); - SPItem *item_use = item; - SPItem *item_use_first = item; - while (is_use && item_use && !clone_with_original) - { - item_use = sp_use_get_original (SP_USE(item_use)); - clone_with_original |= selection->includes(item_use); - if (item_use == item_use_first) - break; - is_use = SP_IS_USE(item_use); - } - if (clone_with_original) - break; - } + bool clone_with_original = selection_contains_both_clone_and_original (selection); if (clone_with_original) { return; // in this version, you cannot clip/mask an object with its own clone } -- 2.30.2