summaryrefslogtreecommitdiffstats
path: root/src/selection-chemistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/selection-chemistry.cpp')
-rw-r--r--src/selection-chemistry.cpp42
1 files 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
}