* 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:
Axel Dörfler
2008-04-18 14:44:19 +00:00
parent 25010b8723
commit f374f0d9f1
+13 -7
View File
@@ -90,15 +90,21 @@ BLayout::AddItem(int32 index, BLayoutItem* item)
bool bool
BLayout::RemoveView(BView* child) BLayout::RemoveView(BView* child)
{ {
int32 index = IndexOfView(child); bool removed = false;
if (index >= 0) {
if (BLayoutItem* item = RemoveItem(index)) { // a view can have any number of layout items - we need to remove them all
delete item; for (int32 i = fItems.CountItems(); i-- > 0;) {
return true; BLayoutItem* item = ItemAt(i);
}
if (item->View() != child)
continue;
RemoveItem(i);
removed = true;
delete item;
} }
return false; return removed;
} }
// RemoveItem // RemoveItem