Group (Group const &);
void ensure_lut () const;
void invalidate_lut () const;
+ void clear_items (bool with_delete);
/* our items, from lowest to highest in the stack */
std::list<Item*> _items;
Group::~Group ()
{
- clear (true);
+ clear_items (true);
}
/** @param area Area to draw in this group's coordinates.
return;
}
- begin_change ();
+ /* we cannot call bounding_box() here because that will iterate over
+ _items, one of which (the argument, i) may be in the middle of
+ deletion, making it impossible to call compute_bounding_box()
+ on it.
+ */
+
+ if (_bounding_box) {
+ _pre_change_bounding_box = _bounding_box;
+ } else {
+ _pre_change_bounding_box = Rect();
+ }
i->unparent ();
_items.remove (i);
{
begin_change ();
- for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
-
- (*i)->unparent ();
-
- if (with_delete) {
- delete *i;
- }
- }
-
- _items.clear ();
+ clear_items (with_delete);
invalidate_lut ();
_bounding_box_dirty = true;
end_change ();
}
+void
+Group::clear_items (bool with_delete)
+{
+ for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ) {
+
+ list<Item*>::iterator tmp = i;
+ Item *item = *i;
+
+ ++tmp;
+
+ /* remove from list before doing anything else, because we
+ * don't want to find the item in _items during any activity
+ * driven by unparent-ing or deletion.
+ */
+
+ _items.erase (i);
+ item->unparent ();
+
+ if (with_delete) {
+ delete item;
+ }
+
+ i = tmp;
+ }
+}
+
void
Group::raise_child_to_top (Item* i)
{