Bug #1474624 fixed (eeschema crashes on a further pressing the DOWN KEY on the last component folder selection)

This commit is contained in:
jean-pierre charras 2015-08-06 11:17:23 +02:00
parent fa29c62277
commit d9ba0b975b
1 changed files with 8 additions and 0 deletions

View File

@ -379,6 +379,9 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite
{ {
wxTreeItemId nextItem; wxTreeItemId nextItem;
if( !item.IsOk() )
return nextItem; // item is not valid: return a not valid wxTreeItemId
if( tree.IsExpanded( item ) ) if( tree.IsExpanded( item ) )
{ {
wxTreeItemIdValue dummy; wxTreeItemIdValue dummy;
@ -386,9 +389,14 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite
} }
else else
{ {
wxTreeItemId root_cell= tree.GetRootItem();
// Walk up levels until we find one that has a next sibling. // Walk up levels until we find one that has a next sibling.
for ( wxTreeItemId walk = item; walk.IsOk(); walk = tree.GetItemParent( walk ) ) for ( wxTreeItemId walk = item; walk.IsOk(); walk = tree.GetItemParent( walk ) )
{ {
if( walk == root_cell ) // the root cell (not displayed) is reached
break; // Exit (calling GetNextSibling( root_cell ) crashes.
nextItem = tree.GetNextSibling( walk ); nextItem = tree.GetNextSibling( walk );
if( nextItem.IsOk() ) if( nextItem.IsOk() )