LayoutItems::iterator it = _layout_items.begin() + index;
LayoutItemRef item = it->layout_item;
- item->setParent(LayoutItemWeakRef());
item->onRemove();
+ item->setParent(LayoutItemWeakRef());
_layout_items.erase(it);
invalidate();
it != _layout_items.end();
++it )
{
- it->layout_item->setParent(LayoutItemWeakRef());
it->layout_item->onRemove();
+ it->layout_item->setParent(LayoutItemWeakRef());
}
_layout_items.clear();
invalidate();
{
_parent = parent;
LayoutItemRef parent_ref = parent.lock();
- setCanvas(parent_ref ? parent_ref->_canvas : CanvasWeakPtr());
+
+ if( parent_ref )
+ // Only change the canvas if there is a new parent. If the item is removed
+ // keep the old canvas, as it may be used for example during the call to
+ // onRemove.
+ setCanvas(parent_ref->_canvas);
setVisibleInternal(!parent_ref || parent_ref->isVisible());
}