From 8dd9b8e6f5f775d156ea24ff4d011e630ec83b3c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 6 Apr 2012 21:04:57 +0300 Subject: [PATCH] Changed Calc errors to be reported only once (not on each update) --- Library/MeasureCalc.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 092f6d44..f8248241 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -28,6 +28,7 @@ bool CMeasureCalc::c_RandSeeded = false; ** */ CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name), + m_ValidFormula(false), m_LowBound(), m_HighBound(100), m_UpdateRandom(false) @@ -57,10 +58,14 @@ bool CMeasureCalc::Update() { if (!CMeasure::PreUpdate()) return false; - const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value); - if (errMsg != NULL) + if (m_ValidFormula) { - LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str()); + const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value); + if (errMsg != NULL) + { + LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str()); + m_ValidFormula = false; + } } return PostUpdate(); @@ -101,7 +106,11 @@ void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section) if (errMsg != NULL) { LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str()); - m_Formula.clear(); + m_ValidFormula = false; + } + else + { + m_ValidFormula = true; } } }