Fixed that Time measure logs invalid format error due to uninitialized m_Time.

http://rainmeter.net/forum/viewtopic.php?f=14&t=13124
This commit is contained in:
spx 2012-08-14 19:51:53 -07:00
parent 956465b96c
commit 7e627cf5f3
2 changed files with 17 additions and 5 deletions

View File

@ -87,11 +87,7 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format,
}
}
/*
** Updates the current time
**
*/
void CMeasureTime::UpdateValue()
void CMeasureTime::FillCurrentTime()
{
FILETIME ftUTCTime;
GetSystemTimeAsFileTime(&ftUTCTime);
@ -102,6 +98,15 @@ void CMeasureTime::UpdateValue()
m_Time.LowPart = ftUTCTime.dwLowDateTime;
m_Time.QuadPart += m_DeltaTime.QuadPart;
}
/*
** Updates the current time
**
*/
void CMeasureTime::UpdateValue()
{
FillCurrentTime();
if (!m_Format.empty())
{
@ -258,4 +263,10 @@ void CMeasureTime::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_DeltaTime.QuadPart = (LONGLONG)(zone * 3600) * 10000000;
}
}
if (!m_Initialized)
{
// Initialize m_Time to avoid causing EINVAL in TimeToString() until calling UpdateValue()
FillCurrentTime();
}
}

View File

@ -37,6 +37,7 @@ protected:
private:
void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const tm* time);
void FillCurrentTime();
std::wstring m_Format;
LARGE_INTEGER m_DeltaTime;