From 3ea301f30e612e8c8b85387e5a1e3d1bef54c894 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Fri, 22 Oct 2010 07:45:43 +0000 Subject: [PATCH] Update BLayout::IndexOfView() to return NULL for NULL input, and check for BViews that where added by BLayout, instead of by BViewLayoutItem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39043 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Layout.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/Layout.cpp b/src/kits/interface/Layout.cpp index 0ccac960ac..0e318fb55c 100644 --- a/src/kits/interface/Layout.cpp +++ b/src/kits/interface/Layout.cpp @@ -251,10 +251,14 @@ BLayout::IndexOfItem(const BLayoutItem* item) const int32 BLayout::IndexOfView(BView* child) const { + if (child == NULL) + return -1; + int itemCount = fItems.CountItems(); for (int32 i = 0; i < itemCount; i++) { BLayoutItem* item = (BLayoutItem*)fItems.ItemAt(i); - if (dynamic_cast(item) && item->View() == child) + if (item->View() == child && (dynamic_cast(item) + || dynamic_cast(item))) return i; }