From 613f13c576c40a791af15c9d7a6aa99571d9dbd8 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 13 Mar 2024 09:39:41 -0400 Subject: [PATCH] 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 (cherry picked from commit 0ff8d2145984116f7cb54c2ae4deeb9d8dc7d9c8) --- eeschema/tools/sch_editor_control.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 50120240e8..f203dcb8a1 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1435,12 +1435,15 @@ void SCH_EDITOR_CONTROL::updatePastedSymbol( SCH_SYMBOL* aSymbol, for( const SCH_SYMBOL_INSTANCE& tmp : aSymbol->GetInstanceReferences() ) { - 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; @@ -1452,7 +1455,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 @@ -1484,7 +1488,8 @@ SCH_SHEET_PATH SCH_EDITOR_CONTROL::updatePastedSheet( SCH_SHEET* aSheet, const KIID_PATH& aClipPath, bool aForceKeepAnnotations, SCH_SHEET_LIST* aPastedSheets, - std::map& aPastedSymbols ) + std::map& aPastedSymbols ) { wxCHECK( aSheet && aPastedSheets, aPastePath );