From 09c3a92d0ae44110e19f277ff9e8349761083884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 5 Apr 2007 11:44:35 +0000 Subject: [PATCH] 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 --- src/kits/interface/OutlineListView.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/OutlineListView.cpp b/src/kits/interface/OutlineListView.cpp index 930e22bff6..3a1e624277 100644 --- a/src/kits/interface/OutlineListView.cpp +++ b/src/kits/interface/OutlineListView.cpp @@ -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()) {