diff --git a/Library/AboutDialog.cpp b/Library/AboutDialog.cpp index 6b4a4024..e8436838 100644 --- a/Library/AboutDialog.cpp +++ b/Library/AboutDialog.cpp @@ -148,12 +148,12 @@ void UpdateAboutStatistics(LPCTSTR entryName) { int count = ListView_GetItemCount(widget); - std::list::const_iterator iter = Rainmeter->m_LogData.begin(); + std::list::const_iterator iter = Rainmeter->GetAboutLogData().begin(); LVITEM vitem; vitem.mask = LVIF_TEXT; int i = 0; - for ( ; iter != Rainmeter->m_LogData.end(); ++iter) + for ( ; iter != Rainmeter->GetAboutLogData().end(); ++iter) { if (i < count) { diff --git a/Library/AboutDialog.h b/Library/AboutDialog.h index 94e7f2da..68449a0e 100644 --- a/Library/AboutDialog.h +++ b/Library/AboutDialog.h @@ -21,6 +21,8 @@ #include "MeterWindow.h" +#define MAXABOUTLOGLINES 20 + HWND OpenAboutDialog(HWND hwndOwner, HINSTANCE instance); void UpdateAboutDialog(); void UpdateAboutStatistics(LPCTSTR entryName = NULL); diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index e51f829d..8f0b4ad9 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -548,10 +548,9 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage) break; } - Rainmeter->m_LogData.push_front(logInfo); - if (Rainmeter->m_LogData.size() > MAXABOUTLOGLINES) + if (Rainmeter) { - Rainmeter->m_LogData.pop_back(); + Rainmeter->AddAboutLogInfo(logInfo); } // Use the lsapi.dll version of the method if possible diff --git a/Library/Litestep.h b/Library/Litestep.h index 082dc713..d37a53fa 100644 --- a/Library/Litestep.h +++ b/Library/Litestep.h @@ -28,7 +28,6 @@ #define LM_GETREVID 9265 #define LM_REGISTERMESSAGE 9263 #define LM_UNREGISTERMESSAGE 9264 -#define MAXABOUTLOGLINES 20 #ifdef _DEBUG #define DEBUGLOG DebugLog diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 11dc0493..41abe159 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1213,6 +1213,8 @@ CRainmeter::CRainmeter() m_TrayWindow = NULL; + InitializeCriticalSection(&m_CsLogData); + INITCOMMONCONTROLSEX initCtrls; initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX); initCtrls.dwICC = ICC_TAB_CLASSES; @@ -1254,6 +1256,8 @@ CRainmeter::~CRainmeter() UpdateDesktopWorkArea(true); } + DeleteCriticalSection(&m_CsLogData); + GdiplusShutdown(m_GDIplusToken); } @@ -3731,6 +3735,19 @@ void CRainmeter::DeleteLogFile() } } +void CRainmeter::AddAboutLogInfo(const LOG_INFO& logInfo) +{ + EnterCriticalSection(&m_CsLogData); + + m_LogData.push_front(logInfo); + if (m_LogData.size() > MAXABOUTLOGLINES) + { + m_LogData.pop_back(); + } + + LeaveCriticalSection(&m_CsLogData); +} + void CRainmeter::SetLogging(bool logging) { m_Logging = logging; diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 13832e66..76649968 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -195,7 +195,9 @@ public: void StartLogging(); void StopLogging(); void DeleteLogFile(); - std::list m_LogData; + + void AddAboutLogInfo(const LOG_INFO& logInfo); + const std::list& GetAboutLogData() { return m_LogData; } void SetDebug(bool debug); @@ -279,6 +281,9 @@ private: bool m_Logging; + std::list m_LogData; + CRITICAL_SECTION m_CsLogData; + std::wstring m_ConfigEditor; std::wstring m_LogViewer;