Now handles two cases of incorrectly built trees gracefully (instead of crashing).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-04-05 11:44:35 +00:00
parent b754aa3dbd
commit 09c3a92d0a

View File

@ -25,7 +25,7 @@ static void
quick_sort_item_array(BListItem** items, int32 first, int32 last,
int (*compareFunc)(const BListItem* a, const BListItem* b))
{
if (last == first)
if (last <= first)
return;
BListItem* pivot = items[first + (rand() % (last - first))];
@ -693,11 +693,9 @@ BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex)
if (item->fLevel < level)
break;
if (item->fLevel == level) {
// If the level matches, put them into the list
list->AddItem(item);
}
// If the level matches, put them into the list
// (we handle the case of a missing sublevel gracefully)
list->AddItem(item);
fullIndex++;
if (item->HasSubitems()) {