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 0ff8d21459)
This commit is contained in:
Wayne Stambaugh 2024-03-13 09:39:41 -04:00
parent 89ed09744b
commit dd71173263
1 changed files with 9 additions and 4 deletions

View File

@ -1437,12 +1437,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;
@ -1454,7 +1457,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
@ -1486,7 +1490,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 );