diff --git a/Library/Measure.cpp b/Library/Measure.cpp index 3251ced1..ff77fd5c 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -63,7 +63,7 @@ CMeasure::CMeasure(CMeterWindow* meterWindow) m_IfEqualCommited = false; m_Disabled = false; m_UpdateDivider = 1; - m_UpdateCounter = 0; + m_UpdateCounter = 1; m_MedianPos = 0; m_AveragePos = 0; m_AverageSize = 0; @@ -98,8 +98,12 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0); m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0); - m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1); - m_UpdateCounter = m_UpdateDivider; + + UINT updateDivider = parser.ReadInt(section, L"UpdateDivider", 1); + if (updateDivider != m_UpdateDivider) + { + m_UpdateCounter = m_UpdateDivider = updateDivider; + } m_MinValue = parser.ReadFloat(section, L"MinValue", m_MinValue); m_MaxValue = parser.ReadFloat(section, L"MaxValue", m_MaxValue); diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index 3847dda6..8d2c3985 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -61,10 +61,26 @@ void CMeterLine::Initialize() { CMeter::Initialize(); - std::vector::iterator i = m_Colors.begin(); - for ( ; i != m_Colors.end(); i++) + if (m_Colors.size() != m_AllValues.size()) { - m_AllValues.push_back(std::vector()); + if (m_Colors.size() > m_AllValues.size()) + { + size_t num = (!m_AllValues.empty()) ? m_AllValues[0].size() : 0; + + for (size_t i = m_AllValues.size(), end = m_Colors.size(); i < end; i++) + { + m_AllValues.push_back(std::vector()); + + if (num > 0) + { + m_AllValues.back().assign(num, 0); + } + } + } + else + { + m_AllValues.resize(m_Colors.size()); + } } } @@ -79,6 +95,9 @@ void CMeterLine::ReadConfig(const WCHAR* section) int i; WCHAR tmpName[256]; + // Store the current number of lines so we know if the buffer needs to be updated + int oldLineCount = (int)m_Colors.size(); + // Read common configs CMeter::ReadConfig(section); @@ -86,6 +105,10 @@ void CMeterLine::ReadConfig(const WCHAR* section) int lineCount = parser.ReadInt(section, L"LineCount", 1); + m_Colors.clear(); + m_ScaleValues.clear(); + m_MeasureNames.clear(); + for (i = 0; i < lineCount; i++) { if (i == 0) @@ -123,6 +146,12 @@ void CMeterLine::ReadConfig(const WCHAR* section) m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0); m_HorizontalColor = parser.ReadColor(section, L"HorizontalColor", Color::Black); // This is left here for backwards compatibility m_HorizontalColor = parser.ReadColor(section, L"HorizontalLineColor", m_HorizontalColor); // This is what it should be + + if (m_Initialized && + oldLineCount != lineCount) + { + Initialize(); + } } /*