Fix broken paste special keep existing symbol annotations.

This was only broken for symbols on the sheet where the symbols were
copied from.  The symbol annotation for all sub-sheets was preserved.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17231
This commit is contained in:
Wayne Stambaugh 2024-03-13 09:39:41 -04:00
parent 7341d4bf37
commit 0ff8d21459
1 changed files with 9 additions and 4 deletions

View File

@ -1438,12 +1438,15 @@ void SCH_EDITOR_CONTROL::updatePastedSymbol( SCH_SYMBOL* aSymbol,
for( const SCH_SYMBOL_INSTANCE& tmp : aSymbol->GetInstances() )
{
if( tmp.m_Path.EndsWith( aClipPath ) )
if( ( tmp.m_Path.empty() && aClipPath.empty() )
|| ( !aClipPath.empty() && tmp.m_Path.EndsWith( aClipPath ) ) )
{
newInstance = tmp;
instanceFound = true;
wxLogDebug( wxS( "Pasting found symbol instance:\n\tpath: %s\n\tuuid: %s." ),
wxLogDebug( wxS( "Pasting found symbol instance with reference %s, unit %d:"
"\n\tClipboard path: %s\n\tSymbol UUID: %s." ),
tmp.m_Reference, tmp.m_Unit,
aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
break;
@ -1455,7 +1458,8 @@ void SCH_EDITOR_CONTROL::updatePastedSymbol( SCH_SYMBOL* aSymbol,
if( !instanceFound )
{
wxLogDebug( wxS( "Clipboard symbol instance **not** found:\n\tpath: %s\n\tuuid: %s." ),
wxLogDebug( wxS( "Clipboard symbol instance **not** found:\n\tClipboard path: %s\n\t"
"Symbol UUID: %s." ),
aClipPath.AsString(), aSymbol->m_Uuid.AsString() );
// Some legacy versions saved value fields escaped. While we still do in the symbol
@ -1487,7 +1491,8 @@ SCH_SHEET_PATH SCH_EDITOR_CONTROL::updatePastedSheet( SCH_SHEET* aSheet,
const KIID_PATH& aClipPath,
bool aForceKeepAnnotations,
SCH_SHEET_LIST* aPastedSheets,
std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST>& aPastedSymbols )
std::map<SCH_SHEET_PATH,
SCH_REFERENCE_LIST>& aPastedSymbols )
{
wxCHECK( aSheet && aPastedSheets, aPastePath );