Fix a bug in BLayout::AddItem() where the right conditions + an error would have
caused the wrongful removal of a BView from its parent.
This commit is contained in:
parent
b8725ee37e
commit
90e615679c
@ -162,10 +162,14 @@ BLayout::AddItem(int32 index, BLayoutItem* item)
|
|||||||
// if the item refers to a BView, we make sure it is added to the parent
|
// if the item refers to a BView, we make sure it is added to the parent
|
||||||
// view
|
// view
|
||||||
BView* view = item->View();
|
BView* view = item->View();
|
||||||
AutoDeleter<BView, ViewRemover> remover(view);
|
AutoDeleter<BView, ViewRemover> remover(NULL);
|
||||||
if (view && view->fParent != fTarget && !fTarget->_AddChild(view, NULL)) {
|
// In case of errors, we don't want to leave this view added where it
|
||||||
remover.Detach(); // view wasn't added
|
// shouldn't be.
|
||||||
|
if (view && view->fParent != fTarget) {
|
||||||
|
if (!fTarget->_AddChild(view, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
else
|
||||||
|
remover.SetTo(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate the index
|
// validate the index
|
||||||
|
Loading…
Reference in New Issue
Block a user