From ad8e5891d24f8f08e67d4486e1e51dd07ad40168 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 6 Dec 2022 17:56:25 -0500 Subject: [PATCH] Properties: update evaluator locale when creating editors --- common/libeval/numeric_evaluator.cpp | 10 ++++++++-- common/widgets/unit_binder.cpp | 1 + include/libeval/numeric_evaluator.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common/libeval/numeric_evaluator.cpp b/common/libeval/numeric_evaluator.cpp index 1bc44646c2..946d3b5ee9 100644 --- a/common/libeval/numeric_evaluator.cpp +++ b/common/libeval/numeric_evaluator.cpp @@ -46,8 +46,7 @@ namespace numEval NUMERIC_EVALUATOR::NUMERIC_EVALUATOR( EDA_UNITS aUnits ) { - struct lconv* lc = localeconv(); - m_localeDecimalSeparator = *lc->decimal_point; + LocaleChanged(); m_parseError = false; m_parseFinished = false; @@ -93,6 +92,13 @@ void NUMERIC_EVALUATOR::SetDefaultUnits( EDA_UNITS aUnits ) } +void NUMERIC_EVALUATOR::LocaleChanged() +{ + struct lconv* lc = localeconv(); + m_localeDecimalSeparator = *lc->decimal_point; +} + + void NUMERIC_EVALUATOR::parseError( const char* s ) { m_parseError = true; diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 667abac5b5..32708c102b 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -139,6 +139,7 @@ void UNIT_BINDER::SetUnits( EDA_UNITS aUnits ) m_units = aUnits; m_eval.SetDefaultUnits( m_units ); + m_eval.LocaleChanged(); // In case locale changed since last run if( m_unitLabel ) m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) ); diff --git a/include/libeval/numeric_evaluator.h b/include/libeval/numeric_evaluator.h index e03ad28a6e..1ef999b6e8 100644 --- a/include/libeval/numeric_evaluator.h +++ b/include/libeval/numeric_evaluator.h @@ -105,6 +105,8 @@ public: void SetDefaultUnits( EDA_UNITS aUnits ); + void LocaleChanged(); + /* Used by the lemon parser */ void parseError(const char* s); void parseOk();