From 2f5174231122a9d6503226a0e9cfa10953975d6a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 25 Apr 2023 15:17:05 +0200 Subject: [PATCH] netlist exporter: export only the field value, even if field name is shown. Previously, when the field name was visible, the exported field value was prefixed by the field name, and this is incorrect. From master branch Fixes #14611 https://gitlab.com/kicad/code/kicad/issues/14611 --- .../netlist_exporters/netlist_exporter_xml.cpp | 15 ++++++++------- eeschema/sch_field.cpp | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 87cae7e6fd..8206553a85 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2013 jp.charras at wanadoo.fr * Copyright (C) 2013-2017 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -137,8 +137,9 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) ) footprint = candidate; - candidate = m_resolveTextVars ? symbol2->GetField( DATASHEET_FIELD )->GetShownText() - : symbol2->GetField( DATASHEET_FIELD )->GetText(); + candidate = m_resolveTextVars + ? symbol2->GetField( DATASHEET_FIELD )->GetShownText( 0, false ) + : symbol2->GetField( DATASHEET_FIELD )->GetText(); if( !candidate.IsEmpty() && ( unit < minUnit || datasheet.IsEmpty() ) ) datasheet = candidate; @@ -151,7 +152,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, && ( unit < minUnit || userFields.count( f.GetName() ) == 0 ) ) { if( m_resolveTextVars ) - userFields[ f.GetName() ] = f.GetShownText(); + userFields[ f.GetName() ] = f.GetShownText( 0, false ); else userFields[ f.GetName() ] = f.GetText(); } @@ -167,7 +168,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars ); if( m_resolveTextVars ) - datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText(); + datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText( 0, false ); else datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetText(); @@ -178,7 +179,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, if( f.GetText().size() ) { if( m_resolveTextVars ) - userFields[ f.GetName() ] = f.GetShownText(); + userFields[ f.GetName() ] = f.GetShownText( 0, false ); else userFields[ f.GetName() ] = f.GetText(); } @@ -315,7 +316,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) xproperty->AddAttribute( wxT( "name" ), fields[jj].GetCanonicalName() ); if( m_resolveTextVars ) - xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText() ); + xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText( 0, false ) ); else xproperty->AddAttribute( wxT( "value" ), fields[jj].GetText() ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index c787682e5d..3cc5f2dbe9 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -195,7 +195,7 @@ wxString SCH_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const wxString text = EDA_TEXT::GetShownText(); - if( IsNameShown() ) + if( IsNameShown() && aAllowExtraText ) text = GetName() << wxS( ": " ) << text; if( text == wxS( "~" ) ) // Legacy placeholder for empty string