fixed setting selection when there are NULL pages in the tree

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38979 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-05-03 00:36:57 +00:00
parent a16a4ab156
commit 6bd02a4367

View File

@ -614,18 +614,18 @@ int wxTreebook::DoSetSelection(size_t pagePos)
// find the next page suitable to be shown: the first (grand)child // find the next page suitable to be shown: the first (grand)child
// of this one with a non-NULL associated page // of this one with a non-NULL associated page
wxTreeItemId childId = m_treeIds[pagePos]; wxTreeItemId childId = m_treeIds[pagePos];
m_actualSelection = pagePos; int actualPagePos = pagePos;
while ( !page && childId.IsOk() ) while ( !page && childId.IsOk() )
{ {
wxTreeItemIdValue cookie; wxTreeItemIdValue cookie;
childId = tree->GetFirstChild( childId, cookie ); childId = tree->GetFirstChild( childId, cookie );
if ( childId.IsOk() ) if ( childId.IsOk() )
{ {
page = wxBookCtrlBase::GetPage(++m_actualSelection); page = wxBookCtrlBase::GetPage(++actualPagePos);
} }
} }
wxASSERT_MSG( page, wxT("no page to show found!") ); m_actualSelection = page ? actualPagePos : m_selection;
} }
if ( page ) if ( page )