* A view can have more than just one LayoutItem, and therefore, we have to
remove them all in RemoveView(). * Also, previously, the wrong LayoutItem could be removed if there was any view that had more than one item around. * IOW using BView::RemoveSelf()/RemoveChild() yourself would have leaked memory in the best case, and would otherwise crash your app if there was any view with more than one LayoutItem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25024 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
25010b8723
commit
f374f0d9f1
@ -67,7 +67,7 @@ BLayout::AddItem(int32 index, BLayoutItem* item)
|
||||
{
|
||||
if (!fView || !item || fItems.HasItem(item))
|
||||
return false;
|
||||
|
||||
|
||||
// if the item refers to a BView, we make sure, it is added to the parent
|
||||
// view
|
||||
BView* view = item->View();
|
||||
@ -90,15 +90,21 @@ BLayout::AddItem(int32 index, BLayoutItem* item)
|
||||
bool
|
||||
BLayout::RemoveView(BView* child)
|
||||
{
|
||||
int32 index = IndexOfView(child);
|
||||
if (index >= 0) {
|
||||
if (BLayoutItem* item = RemoveItem(index)) {
|
||||
delete item;
|
||||
return true;
|
||||
}
|
||||
bool removed = false;
|
||||
|
||||
// a view can have any number of layout items - we need to remove them all
|
||||
for (int32 i = fItems.CountItems(); i-- > 0;) {
|
||||
BLayoutItem* item = ItemAt(i);
|
||||
|
||||
if (item->View() != child)
|
||||
continue;
|
||||
|
||||
RemoveItem(i);
|
||||
removed = true;
|
||||
delete item;
|
||||
}
|
||||
|
||||
return false;
|
||||
return removed;
|
||||
}
|
||||
|
||||
// RemoveItem
|
||||
|
Loading…
Reference in New Issue
Block a user