Fix bug in BView::RemoveSelf() that lead to a segfault.

Once again, the BObjectList removal behaviour leads to a null dereference. It's my fault of course, but there you have it. Comments have been included for future devs.
This commit is contained in:
Alex Wilson
2011-12-01 19:08:56 -07:00
parent 53617d366d
commit f98f5ca48b
+6 -3
View File
@@ -4023,10 +4023,13 @@ bool
BView::RemoveSelf()
{
if (fParent && fParent->fLayoutData->fLayout) {
int32 itemCount = fLayoutData->fLayoutItems.CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = fLayoutData->fLayoutItems.ItemAt(i);
int32 itemsRemaining = fLayoutData->fLayoutItems.CountItems();
while (itemsRemaining-- > 0) {
BLayoutItem* item = fLayoutData->fLayoutItems.ItemAt(0);
// always remove item at index 0, since items are shuffled
// downwards by BObjectList
item->Layout()->RemoveItem(item);
// removes item from fLayoutItems list
delete item;
}
}