From 69a282d4e679bc34ab98425e949008db32410f50 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Feb 1999 15:43:05 +0000 Subject: [PATCH] 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 --- src/generic/treectrl.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index b2ebd5e3a0..d9cb6dbb24 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -1307,14 +1307,15 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event ) } if (prev) { - while (IsExpanded(prev)) + while ( IsExpanded(prev) && HasChildren(prev) ) { - int c = (int)GetChildrenCount( prev, FALSE ); - long cockie = 0; - prev = GetFirstChild( prev, cockie ); - for (int i = 0; i < c-1; i++) - prev = GetNextSibling( prev ); + wxTreeItemId child = GetLastChild(prev); + if ( child ) + { + prev = child; + } } + SelectItem( prev ); EnsureVisible( prev ); } @@ -1341,7 +1342,7 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event ) case WXK_DOWN: { - if (IsExpanded(m_current)) + if (IsExpanded(m_current) && HasChildren(m_current)) { long cookie = 0; wxTreeItemId child = GetFirstChild( m_current, cookie );