* 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:
@@ -67,7 +67,7 @@ BLayout::AddItem(int32 index, BLayoutItem* item)
|
|||||||
{
|
{
|
||||||
if (!fView || !item || fItems.HasItem(item))
|
if (!fView || !item || fItems.HasItem(item))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 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();
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user