diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 9f261f71..42d2bfcd 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1837,6 +1837,7 @@ void CMeterWindow::Update(bool nodraw) // Statistics CMeasureNet::UpdateStats(); + Rainmeter->WriteStats(false); if (!nodraw) { diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index d9017e57..863ec1ce 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -631,7 +631,7 @@ CRainmeter::~CRainmeter() if (m_TrayWindow) delete m_TrayWindow; - WriteStats(); + WriteStats(true); GdiplusShutdown(m_GDIplusToken); } @@ -1636,18 +1636,25 @@ void CRainmeter::ReadStats() /* ** WriteStats ** -** Writes the statistics to the ini-file +** Writes the statistics to the ini-file. If bForce is false the stats are written only once per minute. ** */ -void CRainmeter::WriteStats() +void CRainmeter::WriteStats(bool bForce) { - // Write the date for statistics - WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str()); + static DWORD lastWrite = 0; - // Only Net measure has stats at the moment - CMeasureNet::WriteStats(m_IniFile); + if (bForce || (lastWrite + 1000 * 60 < GetTickCount())) + { + lastWrite = GetTickCount(); - WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); + // Write the date for statistics + WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str()); + + // Only Net measure has stats at the moment + CMeasureNet::WriteStats(m_IniFile); + + WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); + } } /* diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 2a0d094a..2f204318 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -139,7 +139,7 @@ public: void UpdateStats(); void ReadStats(); - void WriteStats(); + void WriteStats(bool bForce); void ResetStats(); BOOL GetCheckUpdate() { return m_CheckUpdate; };