From 60c937186a4333c2aca290e60d85310a54b29ca5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 9 Dec 2022 20:22:10 +0000 Subject: [PATCH] When migrating simulation models update value to a reference. --- eeschema/dialogs/dialog_sim_model.cpp | 11 ++++------- eeschema/sim/sim_model.cpp | 14 ++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index dd5f264bef..1a0124917c 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -136,12 +136,7 @@ template bool DIALOG_SIM_MODEL::TransferDataToWindow() { wxCommandEvent dummyEvent; - - wxString value; - - // Yes, the Value field is always present, but Coverity doesn't know that... - if( T_field* valueField = m_symbol.FindField( wxT( "Value" ) ) ) - value = valueField->GetText(); + T_field* valueField = m_symbol.FindField( wxT( "Value" ) ); // Infer RLC models if they aren't specified if( !m_symbol.FindField( SIM_MODEL::DEVICE_TYPE_FIELD ) @@ -149,7 +144,7 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() { // pair.first: wxString sim model type // pair.second: wxString sim model parameters - auto model = SIM_MODEL::InferSimModel( m_symbol.GetPrefix(), value ); + auto model = SIM_MODEL::InferSimModel( m_symbol.GetPrefix(), valueField->GetText() ); if( !model.second.IsEmpty() ) { @@ -164,6 +159,8 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_fields.emplace_back( &m_symbol, -1, SIM_MODEL::PARAMS_FIELD ); m_fields.back().SetText( model.second ); + + m_fields[ VALUE_FIELD ].SetText( wxT( "${SIM.PARAMS}" ) ); } } diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 23dce0bf04..a1d8abed42 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1065,11 +1065,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol ) } wxString prefix = aSymbol.GetPrefix(); - wxString value; - - // Yes, the Value field is always present, but Coverity doesn't know that... - if( T_field* valueField = aSymbol.FindField( wxT( "Value" ) ) ) - value = valueField->GetText(); + T_field* valueField = aSymbol.FindField( wxT( "Value" ) ); wxString spiceType; wxString spiceModel; @@ -1119,7 +1115,8 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol ) } else { - spiceModel = value; + spiceModel = valueField->GetText(); + valueField->SetText( wxT( "${SIM.PARAMS}" ) ); } if( T_field* netlistEnabledField = aSymbol.FindField( wxT( "Spice_Netlist_Enabled" ) ) ) @@ -1142,7 +1139,8 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol ) } else if( prefix == wxT( "V" ) || prefix == wxT( "I" ) ) { - spiceModel = value; + spiceModel = valueField->GetText(); + valueField->SetText( wxT( "${SIM.PARAMS}" ) ); } else { @@ -1166,7 +1164,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol ) wxStringSplit( legacyPins->GetText(), pinIndexes, ' ' ); - if( SIM_MODEL::InferSimModel( prefix, value ).second.length() ) + if( SIM_MODEL::InferSimModel( prefix, valueField->GetText() ).second.length() ) { if( pinIndexes[0] == wxT( "2" ) ) pins = "1=- 2=+";