canvas::Layout: clear parent/canvas after calling onRemove.
This commit is contained in:
@@ -125,8 +125,8 @@ namespace canvas
|
||||
|
||||
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();
|
||||
@@ -141,8 +141,8 @@ namespace canvas
|
||||
it != _layout_items.end();
|
||||
++it )
|
||||
{
|
||||
it->layout_item->setParent(LayoutItemWeakRef());
|
||||
it->layout_item->onRemove();
|
||||
it->layout_item->setParent(LayoutItemWeakRef());
|
||||
}
|
||||
_layout_items.clear();
|
||||
invalidate();
|
||||
|
||||
@@ -163,7 +163,12 @@ namespace canvas
|
||||
{
|
||||
_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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user