From 5d9668938b917bb620ce6f121728c2564a5ad6f6 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 1 Apr 2022 10:42:20 +0200 Subject: [PATCH] SYMBOL_EDITOR_CONTROL::DuplicateSymbol(): fix incorrect validation test. DuplicateSymbol() is called both to duplicate and paste. Only duplicate needs a test to know if a symbol is selected. Fixes #11053 https://gitlab.com/kicad/code/kicad/issues/11053 --- eeschema/tools/symbol_editor_control.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index a29b48a00f..cc6cdb4e27 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -256,10 +256,14 @@ int SYMBOL_EDITOR_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent ) { SYMBOL_EDIT_FRAME* editFrame = static_cast( m_frame ); LIB_ID sel = editFrame->GetTargetLibId(); + // DuplicateSymbol() is called to duplicate a symbol, or to paste a previously + // saved symbol in clipboard + bool isPasteAction = aEvent.IsAction( &EE_ACTIONS::pasteSymbol ); wxString msg; - if( !sel.IsValid() ) + if( !sel.IsValid() && !isPasteAction ) { + // When duplicating a symbol, a source symbol must exists. msg.Printf( _( "No symbol selected" ) ); m_frame->ShowInfoBarError( msg ); return 0; @@ -274,7 +278,7 @@ int SYMBOL_EDITOR_CONTROL::DuplicateSymbol( const TOOL_EVENT& aEvent ) return 0; } - editFrame->DuplicateSymbol( aEvent.IsAction( &EE_ACTIONS::pasteSymbol ) ); + editFrame->DuplicateSymbol( isPasteAction ); } return 0;