From fa366cbe40ca836e09274cf5b7cd1aa6acbd7299 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 29 Jun 2008 18:54:28 +0000 Subject: [PATCH] Accidentally broke CountItemsUnder() for invalid items with previous commit. This fixes VLC, which for some reason calls CountItemsUnder(NULL) quite a few times on startup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26167 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/OutlineListView.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/OutlineListView.cpp b/src/kits/interface/OutlineListView.cpp index 2fc659c8e6..f6b9ba62e0 100644 --- a/src/kits/interface/OutlineListView.cpp +++ b/src/kits/interface/OutlineListView.cpp @@ -688,24 +688,24 @@ int32 BOutlineListView::CountItemsUnder(BListItem* underItem, bool oneLevelOnly) const { - int32 i = FullListIndexOf(underItem) + 1; + int32 i = FullListIndexOf(underItem); if (i == -1) return 0; - + + ++i; int32 count = 0; + uint32 baseLevel = underItem->OutlineLevel(); - while (i < FullListCountItems()) { + for (; i < FullListCountItems(); i++) { BListItem *item = FullListItemAt(i); // If we jump out of the subtree, return count - if (item->fLevel <= underItem->OutlineLevel()) + if (item->fLevel <= baseLevel) return count; // If the level matches, increase count - if (!oneLevelOnly || item->fLevel == underItem->OutlineLevel() + 1) + if (!oneLevelOnly || item->fLevel == baseLevel + 1) count++; - - i++; } return count;