From f3a6bc665147f6a0f1c4498482fe537f05955d9d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 20 Dec 2017 09:44:14 +0100 Subject: [PATCH] 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 --- eeschema/libedit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 00cb6e741c..0f3786c21f 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -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() ); } }