From d9ba0b975bbe0240500b6f4560c8759235e60068 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 6 Aug 2015 11:17:23 +0200 Subject: [PATCH] Bug #1474624 fixed (eeschema crashes on a further pressing the DOWN KEY on the last component folder selection) --- eeschema/dialogs/dialog_choose_component.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 83d2d14ce5..2da30687e0 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -379,6 +379,9 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite { wxTreeItemId nextItem; + if( !item.IsOk() ) + return nextItem; // item is not valid: return a not valid wxTreeItemId + if( tree.IsExpanded( item ) ) { wxTreeItemIdValue dummy; @@ -386,9 +389,14 @@ static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& ite } else { + wxTreeItemId root_cell= tree.GetRootItem(); + // Walk up levels until we find one that has a next sibling. 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 ); if( nextItem.IsOk() )