From 6b29c346b980737f2c325806ff2bd39624276257 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 27 Oct 2023 16:59:14 +0100 Subject: [PATCH] When presented with empty text we don't want to Normalize() the SIM_VALUE. But we *do* need to update NUMERICAL_EVALUATOR::m_originalText by calling NUMERICAL_EVALUATOR::Process(). Fixes https://gitlab.com/kicad/code/kicad/-/issues/15871 --- eeschema/sim/sim_property.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/eeschema/sim/sim_property.cpp b/eeschema/sim/sim_property.cpp index 6f518dcd23..408d82cdf2 100644 --- a/eeschema/sim/sim_property.cpp +++ b/eeschema/sim/sim_property.cpp @@ -194,17 +194,20 @@ bool SIM_STRING_PROPERTY::StringToValue( wxVariant& aVariant, const wxString& aT wxString text = aText; - if( !aText.IsEmpty() && allowEval() && m_needsEval && m_eval.Process( aText ) ) + if( allowEval() && m_needsEval && m_eval.Process( aText ) ) { - double value = SIM_VALUE::ToDouble( m_eval.Result().ToStdString() ); + if( !aText.IsEmpty() ) + { + double value = SIM_VALUE::ToDouble( m_eval.Result().ToStdString() ); - if( std::isnan( value ) || SIM_VALUE::Equal( value, aText.ToStdString() ) ) - { - // Don't mess up user formatting if eval'ing didn't actually change the value. - } - else - { - text = SIM_VALUE::Normalize( value ); + if( std::isnan( value ) || SIM_VALUE::Equal( value, aText.ToStdString() ) ) + { + // Don't mess up user formatting if eval'ing didn't actually change the value. + } + else + { + text = SIM_VALUE::Normalize( value ); + } } }