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; } } }