IfActions: Read condition options after measure value is changed to properly support section variables

This commit is contained in:
Birunthan Mohanathas
2013-11-05 20:43:04 +02:00
parent cf86d365ad
commit b62fca59d0
5 changed files with 32 additions and 90 deletions

View File

@ -131,6 +131,13 @@ void Measure::ReadOptions(ConfigParser& parser, const WCHAR* section)
m_IfActions.ReadOptions(parser, section);
// The first time around, we read the conditions here. Subsequent rereads will be done in
// Update() if needed.
if (!m_Initialized)
{
m_IfActions.ReadConditionOptions(parser, section);
}
m_OnChangeAction = parser.ReadString(section, L"OnChangeAction", L"", false);
m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0);
@ -437,8 +444,13 @@ std::wstring Measure::ExtractWord(std::wstring& buffer)
return ret;
}
bool Measure::Update()
bool Measure::Update(bool rereadOptions)
{
if (rereadOptions)
{
ReadOptions(m_MeterWindow->GetParser());
}
// Don't do anything if paused
if (m_Paused) return false;
@ -497,6 +509,13 @@ bool Measure::Update()
m_ValueAssigned = true;
// For the conditional options to work with the current measure value when using
// [MeasureName], we need to read the options after m_Value has been changed.
if (rereadOptions)
{
m_IfActions.ReadConditionOptions(m_MeterWindow->GetParser(), GetName());
}
if (m_MeterWindow)
{
m_IfActions.DoIfActions(m_Value);