From 9047a3c13904c27ad4aa3821197d8e8caefd0347 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 May 2000 06:01:58 +0000 Subject: [PATCH] fix for crash in wxTreeCtrl::GetSelections() when the tree is empty git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectrl.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index 59a20f9274..61b300f070 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -1407,14 +1407,19 @@ void wxTreeCtrl::FillArray(wxGenericTreeItem *item, wxArrayGenericTreeItems& children = item->GetChildren(); size_t count = children.GetCount(); for ( size_t n = 0; n < count; ++n ) - FillArray(children[n],array); + FillArray(children[n], array); } } size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds &array) const { array.Empty(); - FillArray(GetRootItem().m_pItem, array); + wxTreeItemId idRoot = GetRootItem(); + if ( idRoot.IsOk() ) + { + FillArray(idRoot.m_pItem, array); + } + //else: the tree is empty, so no selections return array.Count(); }