From c91c028c376625c1a842d75119af6251fb5df810 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 18 Jan 2017 10:21:58 +0100 Subject: do not add items twice to their canvas parent! --- libs/canvas/canvas/item.h | 2 +- libs/canvas/item.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index dc29e75677..dacb9d559b 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -99,7 +99,7 @@ public: void ungrab (); void unparent (); - void reparent (Item *); + void reparent (Item *, bool already_added = false); /** @return Parent group, or 0 if this is the root group */ Item* parent () const { diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index e2cdc698bb..706a62b717 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -410,7 +410,7 @@ Item::unparent () } void -Item::reparent (Item* new_parent) +Item::reparent (Item* new_parent, bool already_added) { if (new_parent == _parent) { return; @@ -429,7 +429,9 @@ Item::reparent (Item* new_parent) find_scroll_parent (); - _parent->add (this); + if (!already_added) { + _parent->add (this); + } } void @@ -862,7 +864,7 @@ Item::add (Item* i) /* XXX should really notify canvas about this */ _items.push_back (i); - i->reparent (this); + i->reparent (this, true); invalidate_lut (); _bounding_box_dirty = true; } @@ -873,7 +875,7 @@ Item::add_front (Item* i) /* XXX should really notify canvas about this */ _items.push_front (i); - i->reparent (this); + i->reparent (this, true); invalidate_lut (); _bounding_box_dirty = true; } -- cgit v1.2.3