Duplicate from selected or current

When double-clicking to open a symbol, it is no longer selected in the
tree.  We need to use the `GetTargetLibId()` to pick the correct symbol
(first selected, then current) when using the duplicate command

Fixes https://gitlab.com/kicad/code/kicad/issues/11034

(cherry picked from commit 802d20c409)
This commit is contained in:
Seth Hillbrand 2022-03-03 15:19:24 -08:00
parent b5c2f0d39a
commit 7ecc70a79d
2 changed files with 11 additions and 5 deletions

View File

@ -828,8 +828,7 @@ void SYMBOL_EDIT_FRAME::CopySymbolToClipboard()
void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard ) void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
{ {
int dummyUnit; LIB_ID libId = GetTargetLibId();
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
wxString lib = libId.GetLibNickname(); wxString lib = libId.GetLibNickname();
if( !m_libMgr->LibraryExists( lib ) ) if( !m_libMgr->LibraryExists( lib ) )

View File

@ -160,7 +160,7 @@ int SYMBOL_EDITOR_CONTROL::AddSymbol( const TOOL_EVENT& aEvent )
if( libName.IsEmpty() ) if( libName.IsEmpty() )
{ {
msg.Printf( _( "No symbol library selected." ), libName ); msg.Printf( _( "No symbol library selected." ) );
m_frame->ShowInfoBarError( msg ); m_frame->ShowInfoBarError( msg );
return 0; return 0;
} }
@ -255,10 +255,17 @@ int SYMBOL_EDITOR_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent )
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{ {
SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame ); SYMBOL_EDIT_FRAME* editFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
LIB_ID sel = editFrame->GetTargetLibId();
wxString msg;
if( !sel.IsValid() )
{
msg.Printf( _( "No symbol selected" ) );
m_frame->ShowInfoBarError( msg );
return 0;
}
LIB_ID sel = editFrame->GetTreeLIBID();
const wxString& libName = sel.GetLibNickname(); const wxString& libName = sel.GetLibNickname();
wxString msg;
if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) ) if( editFrame->GetLibManager().IsLibraryReadOnly( libName ) )
{ {