fix crash in wxDataViewItem GetNextItem() when there are no item.

Fixes #9540
https://gitlab.com/kicad/code/kicad/issues/9540
This commit is contained in:
jean-pierre charras 2021-11-07 08:53:56 +01:00
parent 97e9348ee1
commit 4293caf00c
1 changed files with 11 additions and 2 deletions

View File

@ -42,20 +42,29 @@ wxDataViewItem GetPrevItem( wxDataViewCtrl const& aView, wxDataViewItem const& a
wxDataViewItem GetNextItem( wxDataViewCtrl const& aView, wxDataViewItem const& aItem )
{
wxDataViewItem nextItem;
wxDataViewItem invalid;
if( !aItem.IsOk() )
{
// No selection. Select the first.
wxDataViewItemArray children;
aView.GetModel()->GetChildren( aItem, children );
if( children.size() )
return children[0];
return invalid;
}
if( aView.IsExpanded( aItem ) )
{
wxDataViewItemArray children;
aView.GetModel()->GetChildren( aItem, children );
nextItem = children[0];
if( children.size() )
return children[0];
return invalid;
}
else
{