Fix crash on cut/remove a part in symbol library editor

Fixes: lp:1738635
* https://bugs.launchpad.net/kicad/+bug/1738635

Fixes: lp:1738999
* https://bugs.launchpad.net/kicad/+bug/1738999
This commit is contained in:
Maciej Suminski 2017-12-20 09:44:14 +01:00
parent 7741b90c78
commit f3a6bc6651
1 changed files with 8 additions and 0 deletions

View File

@ -374,6 +374,10 @@ void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent )
if( isCurrentPart( libId ) )
emptyScreen();
// Keeping a removed item selected may lead to a crash
if( m_treePane->GetCmpTree()->GetSelectedLibId( nullptr ) == libId )
m_treePane->GetCmpTree()->SelectLibId( LIB_ID( libId.GetLibNickname(), "" ) );
m_libMgr->RemovePart( libId.GetLibItemName(), libId.GetLibNickname() );
}
@ -395,6 +399,10 @@ void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent )
if( isCurrentPart( libId ) )
emptyScreen();
// Keeping a removed item selected may lead to a crash
if( m_treePane->GetCmpTree()->GetSelectedLibId( nullptr ) == libId )
m_treePane->GetCmpTree()->SelectLibId( LIB_ID( libId.GetLibNickname(), "" ) );
m_libMgr->RemovePart( libId.GetLibItemName(), libId.GetLibNickname() );
}
}