mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed DebugLog and LuaLog more reliably. (Fixed an issue that Rainmeter crashes if format parameter includes '%'.)
This commit is contained in:
parent
e2d9a6cc71
commit
aa3ad1fc8f
@ -600,12 +600,29 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
void DebugLog(const WCHAR* format, ... )
|
void DebugLog(const WCHAR* format, ... )
|
||||||
{
|
{
|
||||||
WCHAR buffer[4096];
|
WCHAR buffer[4096];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start( args, format );
|
va_start( args, format );
|
||||||
|
|
||||||
|
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||||
|
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
_vsnwprintf_s( buffer, 4096, _TRUNCATE, format, args );
|
_vsnwprintf_s( buffer, 4096, _TRUNCATE, format, args );
|
||||||
|
if (errno != 0)
|
||||||
|
{
|
||||||
|
_snwprintf_s(buffer, 4096, _TRUNCATE, L"DebugLog internal error: %s", format);
|
||||||
|
}
|
||||||
|
|
||||||
|
_set_invalid_parameter_handler(oldHandler);
|
||||||
|
|
||||||
LSLog(LOG_DEBUG, L"Rainmeter", buffer);
|
LSLog(LOG_DEBUG, L"Rainmeter", buffer);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ BOOL RemoveBangCommand(LPCSTR command);
|
|||||||
void TransparentBltLS (HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
|
void TransparentBltLS (HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
|
||||||
void VarExpansion(LPSTR buffer, LPCSTR value);
|
void VarExpansion(LPSTR buffer, LPCSTR value);
|
||||||
void LSSetVariable(const BSTR name, const BSTR value);
|
void LSSetVariable(const BSTR name, const BSTR value);
|
||||||
|
|
||||||
|
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);
|
||||||
void DebugLog(const WCHAR* message, ... );
|
void DebugLog(const WCHAR* message, ... );
|
||||||
|
|
||||||
void ResetLoggingFlag();
|
void ResetLoggingFlag();
|
||||||
|
@ -22,11 +22,6 @@
|
|||||||
#include "MeasureTime.h"
|
#include "MeasureTime.h"
|
||||||
#include "Rainmeter.h"
|
#include "Rainmeter.h"
|
||||||
|
|
||||||
void MeasureTime_CRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
|
|
||||||
{
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetYearDay(int year, int month, int day)
|
int GetYearDay(int year, int month, int day)
|
||||||
{
|
{
|
||||||
int yearDay = 0;
|
int yearDay = 0;
|
||||||
@ -86,7 +81,7 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format,
|
|||||||
{
|
{
|
||||||
if (bufLen > 0)
|
if (bufLen > 0)
|
||||||
{
|
{
|
||||||
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(MeasureTime_CRTInvalidParameterHandler);
|
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||||
_CrtSetReportMode(_CRT_ASSERT, 0);
|
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -59,7 +59,17 @@ void LuaManager::LuaLog(const char* format, ... )
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start( args, format );
|
va_start( args, format );
|
||||||
|
|
||||||
_vsnprintf_s(buffer, 4096, _TRUNCATE, format, args );
|
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||||
|
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
_vsnprintf_s( buffer, 4096, _TRUNCATE, format, args );
|
||||||
|
if (errno != 0)
|
||||||
|
{
|
||||||
|
_snprintf_s(buffer, 4096, _TRUNCATE, "LuaLog internal error: %s", format);
|
||||||
|
}
|
||||||
|
|
||||||
|
_set_invalid_parameter_handler(oldHandler);
|
||||||
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
// Forcing output to the Debug Output window!
|
// Forcing output to the Debug Output window!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user