From e695c580fdd8b2e8777f9064770ab8d1040bd594 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 30 Jun 2021 12:32:23 +0100 Subject: [PATCH] Resolve textvar cross-references even if the field doesn't exist. Fixes https://gitlab.com/kicad/code/kicad/issues/8701 --- eeschema/schematic.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index 07e6cb1e5f..1a8fdf8bcb 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -216,28 +216,28 @@ bool SCHEMATIC::ResolveCrossReference( wxString* token, int aDepth ) const SCH_SHEET_LIST sheetList = GetSheets(); wxString remainder; wxString ref = token->BeforeFirst( ':', &remainder ); - SCH_SHEET_PATH dummy; - SCH_ITEM* refItem = sheetList.GetItem( KIID( ref ), &dummy ); + SCH_SHEET_PATH sheetPath; + SCH_ITEM* refItem = sheetList.GetItem( KIID( ref ), &sheetPath ); if( refItem && refItem->Type() == SCH_SYMBOL_T ) { SCH_SYMBOL* refSymbol = static_cast( refItem ); if( refSymbol->ResolveTextVar( &remainder, aDepth + 1 ) ) - { *token = remainder; - return true; - } + else + *token = refSymbol->GetRef( &sheetPath, true ) + ":" + remainder; + + return true; // Cross-reference is resolved whether or not the actual textvar was } else if( refItem && refItem->Type() == SCH_SHEET_T ) { SCH_SHEET* refSheet = static_cast( refItem ); if( refSheet->ResolveTextVar( &remainder, aDepth + 1 ) ) - { *token = remainder; - return true; - } + + return true; // Cross-reference is resolved whether or not the actual textvar was } return false; @@ -282,11 +282,7 @@ wxString SCHEMATIC::ConvertRefsToKIIDs( const wxString& aSource ) const if( ref == refSymbol->GetRef( &references[ jj ].GetSheetPath(), true ) ) { - wxString test( remainder ); - - if( refSymbol->ResolveTextVar( &test ) ) - token = refSymbol->m_Uuid.AsString() + ":" + remainder; - + token = refSymbol->m_Uuid.AsString() + ":" + remainder; break; } }