crash in some very special case when arrows were used to move around fixed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-02-23 15:43:05 +00:00
parent 0b5efdc724
commit 69a282d4e6

View File

@ -1307,14 +1307,15 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event )
} }
if (prev) if (prev)
{ {
while (IsExpanded(prev)) while ( IsExpanded(prev) && HasChildren(prev) )
{ {
int c = (int)GetChildrenCount( prev, FALSE ); wxTreeItemId child = GetLastChild(prev);
long cockie = 0; if ( child )
prev = GetFirstChild( prev, cockie ); {
for (int i = 0; i < c-1; i++) prev = child;
prev = GetNextSibling( prev ); }
} }
SelectItem( prev ); SelectItem( prev );
EnsureVisible( prev ); EnsureVisible( prev );
} }
@ -1341,7 +1342,7 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event )
case WXK_DOWN: case WXK_DOWN:
{ {
if (IsExpanded(m_current)) if (IsExpanded(m_current) && HasChildren(m_current))
{ {
long cookie = 0; long cookie = 0;
wxTreeItemId child = GetFirstChild( m_current, cookie ); wxTreeItemId child = GetFirstChild( m_current, cookie );