From 2186b2eb2ac523e978376fb79cd38e34c3d4840a Mon Sep 17 00:00:00 2001 From: spx Date: Thu, 25 Nov 2010 23:57:10 +0000 Subject: [PATCH] Fixed an issue that ReadConfig() is called unnecessarily when DynamicVariables=1 and UpdateDivider=* are set. --- Library/Measure.h | 19 +++++++++++-------- Library/Meter.h | 3 +++ Library/MeterWindow.cpp | 6 ++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Library/Measure.h b/Library/Measure.h index 6fb5deff..9a201256 100644 --- a/Library/Measure.h +++ b/Library/Measure.h @@ -37,13 +37,13 @@ public: virtual const WCHAR* GetStats(); - void SetName(const WCHAR* name) { m_Name = name; m_ANSIName = ConvertToAscii(name); }; - const WCHAR* GetName() { return m_Name.c_str(); }; - const char* GetANSIName() { return m_ANSIName.c_str(); }; + void SetName(const WCHAR* name) { m_Name = name; m_ANSIName = ConvertToAscii(name); } + const WCHAR* GetName() { return m_Name.c_str(); } + const char* GetANSIName() { return m_ANSIName.c_str(); } - void Disable() { m_Disabled = true; }; - void Enable() { m_Disabled = false; }; - bool IsDisabled() { return m_Disabled; }; + void Disable() { m_Disabled = true; } + void Enable() { m_Disabled = false; } + bool IsDisabled() { return m_Disabled; } bool HasDynamicVariables() { return m_DynamicVariables; } @@ -52,8 +52,11 @@ public: double GetValue(); double GetRelativeValue(); double GetValueRange(); - double GetMinValue() { return m_MinValue; }; - double GetMaxValue() { return m_MaxValue; }; + double GetMinValue() { return m_MinValue; } + double GetMaxValue() { return m_MaxValue; } + + UINT GetUpdateCounter() { return m_UpdateCounter; } + UINT GetUpdateDivider() { return m_UpdateDivider; } virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual); static void GetScaledValue(int decimals, double theValue, WCHAR* buffer); diff --git a/Library/Meter.h b/Library/Meter.h index e2d2ac6d..2b59027c 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -89,6 +89,9 @@ public: void SetName(const WCHAR* name) { m_Name = name; } const WCHAR* GetName() { return m_Name.c_str(); } + UINT GetUpdateCounter() { return m_UpdateCounter; } + UINT GetUpdateDivider() { return m_UpdateDivider; } + static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow); static void DrawBevel(Gdiplus::Graphics& graphics, Gdiplus::Rect& rect, Gdiplus::Pen& light, Gdiplus::Pen& dark); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 1184b40e..878b2aec 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2409,7 +2409,8 @@ void CMeterWindow::Update(bool nodraw) std::list::const_iterator i = m_Measures.begin(); for( ; i != m_Measures.end(); ++i) { - if ((*i)->HasDynamicVariables()) + if ((*i)->HasDynamicVariables() && + ((*i)->GetUpdateCounter() + 1) >= (*i)->GetUpdateDivider()) { try { @@ -2429,7 +2430,8 @@ void CMeterWindow::Update(bool nodraw) std::list::const_iterator j = m_Meters.begin(); for( ; j != m_Meters.end(); ++j) { - if ((*j)->HasDynamicVariables()) + if ((*j)->HasDynamicVariables() && + ((*j)->GetUpdateCounter() + 1) >= (*j)->GetUpdateDivider()) { try {