diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h index 56cdc010b9..f0158e0a96 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.h +++ b/eeschema/netlist_exporters/netlist_exporter_base.h @@ -111,6 +111,9 @@ protected: /// The schematic we're generating a netlist for SCHEMATIC* m_schematic; + /// The schematic's CurrentSheet when we entered. Restore on exiting. + SCH_SHEET_PATH m_savedCurrentSheet; + /** * Function findNextSymbolAndCreatePinList * finds a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList. This @@ -165,10 +168,12 @@ public: m_schematic( aSchematic ) { wxASSERT( aSchematic ); + m_savedCurrentSheet = m_schematic->CurrentSheet(); } virtual ~NETLIST_EXPORTER_BASE() { + m_schematic->SetCurrentSheet( m_savedCurrentSheet ); } /** diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 4ba28d0617..ad16627d25 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -162,15 +162,8 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_COMPONENT* aSymbol } else { - if( m_resolveTextVars ) - fields.value = aSymbol->GetField( VALUE_FIELD )->GetShownText(); - else - fields.value = aSymbol->GetField( VALUE_FIELD )->GetText(); - - if( m_resolveTextVars ) - fields.footprint = aSymbol->GetField( FOOTPRINT_FIELD )->GetShownText(); - else - fields.footprint = aSymbol->GetField( FOOTPRINT_FIELD )->GetText(); + fields.value = aSymbol->GetValue( aSheet, m_resolveTextVars ); + fields.footprint = aSymbol->GetFootprint( aSheet, m_resolveTextVars ); if( m_resolveTextVars ) fields.datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText(); @@ -235,6 +228,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) for( unsigned ii = 0; ii < sheetList.size(); ii++ ) { SCH_SHEET_PATH sheet = sheetList[ii]; + m_schematic->SetCurrentSheet( sheet ); auto cmp = [sheet]( SCH_COMPONENT* a, SCH_COMPONENT* b ) { @@ -244,7 +238,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) std::set ordered_symbols( cmp ); - for( SCH_ITEM* item : sheetList[ii].LastScreen()->Items().OfType( SCH_COMPONENT_T ) ) + for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) ) { SCH_COMPONENT* symbol = static_cast( item ); auto test = ordered_symbols.insert( symbol ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 33905c04c4..74609006d2 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -576,12 +576,9 @@ const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet, bool aResol { if( instance.m_Path == path && !instance.m_Value.IsEmpty() ) { - if( !aResolve ) - return instance.m_Value; - - SCH_FIELD dummy( wxDefaultPosition, VALUE_FIELD, const_cast( this ) ); - dummy.SetText( instance.m_Value ); - return dummy.GetShownText(); + // This can only be an override from an Update Schematic from PCB, and therefore + // will always be fully resolved. + return instance.m_Value; } } @@ -629,12 +626,9 @@ const wxString SCH_COMPONENT::GetFootprint( const SCH_SHEET_PATH* sheet, bool aR { if( instance.m_Path == path && !instance.m_Footprint.IsEmpty() ) { - if( !aResolve ) - return instance.m_Footprint; - - SCH_FIELD dummy( wxDefaultPosition, FOOTPRINT_FIELD, const_cast( this ) ); - dummy.SetText( instance.m_Footprint ); - return dummy.GetShownText(); + // This can only be an override from an Update Schematic from PCB, and therefore + // will always be fully resolved. + return instance.m_Footprint; } }