mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Replaced throw with Log where possible
This commit is contained in:
parent
df61f5c1f8
commit
ea67809d9b
@ -796,13 +796,7 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, cons
|
||||
return new CMeasureScript(meterWindow, name);
|
||||
}
|
||||
|
||||
// Error
|
||||
std::wstring error = L"Measure=";
|
||||
error += measure;
|
||||
error += L" is not valid in [";
|
||||
error += name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"Measure=%s is not valid in [%s]", measure, name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -60,12 +60,7 @@ bool CMeasureCalc::Update()
|
||||
const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value);
|
||||
if (errMsg != NULL)
|
||||
{
|
||||
std::wstring error = L"Calc: ";
|
||||
error += errMsg;
|
||||
error += L" in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
Log(LOG_ERROR, error.c_str());
|
||||
LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str());
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
@ -105,12 +100,8 @@ void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
const WCHAR* errMsg = MathParser::Check(m_Formula.c_str());
|
||||
if (errMsg != NULL)
|
||||
{
|
||||
std::wstring error = L"Calc: ";
|
||||
error += errMsg;
|
||||
error += L" in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str());
|
||||
m_Formula.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +169,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
if (m_Plugin == NULL)
|
||||
{
|
||||
std::wstring error = L"Plugin: \"" + pluginName;
|
||||
error += L"\" not found";
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"Plugin: \"%s\" not found", pluginName.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||
m_RegKey(),
|
||||
m_HKey()
|
||||
m_HKey(HKEY_CURRENT_USER)
|
||||
{
|
||||
m_MaxValue = 0.0;
|
||||
}
|
||||
@ -138,12 +138,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"RegHKey=";
|
||||
error += keyname;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"RegHKey=%s is not valid in [%s]", keyname, m_Name.c_str());
|
||||
}
|
||||
|
||||
m_RegKeyName = parser.ReadString(section, L"RegKey", L"");
|
||||
|
@ -488,13 +488,7 @@ CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHA
|
||||
return new CMeterButton(meterWindow, name);
|
||||
}
|
||||
|
||||
// Error
|
||||
std::wstring error = L"Meter=";
|
||||
error += meter;
|
||||
error += L" is not valid in [";
|
||||
error += name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"Meter=%s is not valid in [%s]", meter, name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -122,12 +122,7 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"BarOrientation=";
|
||||
error += orientation;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"BarOrientation=%s is not valid in [%s]", orientation, m_Name.c_str());
|
||||
}
|
||||
|
||||
if (m_Initialized)
|
||||
|
@ -201,12 +201,7 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"BitmapAlign=";
|
||||
error += align;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"BitmapAlign=%s is not valid in [%s]", align, m_Name.c_str());
|
||||
}
|
||||
|
||||
if (m_Initialized)
|
||||
|
@ -191,8 +191,7 @@ void CMeterString::Initialize()
|
||||
// It couldn't find the font family: Log it.
|
||||
if (Ok != status)
|
||||
{
|
||||
std::wstring error = L"String: Unable to load font: " + m_FontFace;
|
||||
Log(LOG_ERROR, error.c_str());
|
||||
LogWithArgs(LOG_ERROR, L"String: Unable to load font: %s", m_FontFace.c_str());
|
||||
|
||||
delete m_FontFamily;
|
||||
m_FontFamily = NULL;
|
||||
@ -357,12 +356,7 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"StringAlign=";
|
||||
error += align;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"StringAlign=%s is not valid in [%s]", align, m_Name.c_str());
|
||||
}
|
||||
|
||||
const WCHAR* stringCase = parser.ReadString(section, L"StringCase", L"NONE").c_str();
|
||||
@ -384,12 +378,7 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"StringCase=";
|
||||
error += stringCase;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"StringCase=%s is not valid in [%s]", stringCase, m_Name.c_str());
|
||||
}
|
||||
|
||||
const WCHAR* style = parser.ReadString(section, L"StringStyle", L"NORMAL").c_str();
|
||||
@ -411,12 +400,7 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"StringStyle=";
|
||||
error += style;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"StringStyle=%s is not valid in [%s]", style, m_Name.c_str());
|
||||
}
|
||||
|
||||
const WCHAR* effect = parser.ReadString(section, L"StringEffect", L"NONE").c_str();
|
||||
@ -434,12 +418,7 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"StringEffect=";
|
||||
error += effect;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"StringEffect=%s is not valid in [%s]", effect, m_Name.c_str());
|
||||
}
|
||||
|
||||
if (m_Initialized &&
|
||||
|
@ -157,6 +157,17 @@ CMeterWindow::CMeterWindow(const std::wstring& config, const std::wstring& iniFi
|
||||
}
|
||||
}
|
||||
|
||||
if (c_InstanceCount == 0)
|
||||
{
|
||||
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
|
||||
wc.style = CS_NOCLOSE | CS_DBLCLKS;
|
||||
wc.lpfnWndProc = InitialWndProc;
|
||||
wc.hInstance = m_Rainmeter->GetInstance();
|
||||
wc.hCursor = NULL; // The cursor should be controlled by using SetCursor() when needed.
|
||||
wc.lpszClassName = METERWINDOW_CLASS_NAME;
|
||||
RegisterClassEx(&wc);
|
||||
}
|
||||
|
||||
++c_InstanceCount;
|
||||
}
|
||||
|
||||
@ -211,16 +222,7 @@ CMeterWindow::~CMeterWindow()
|
||||
|
||||
if (c_InstanceCount == 0)
|
||||
{
|
||||
BOOL Result;
|
||||
int counter = 0;
|
||||
do
|
||||
{
|
||||
// Wait for the window to die
|
||||
Result = UnregisterClass(METERWINDOW_CLASS_NAME, m_Rainmeter->GetInstance());
|
||||
Sleep(100);
|
||||
++counter;
|
||||
}
|
||||
while(!Result && counter < 10);
|
||||
UnregisterClass(METERWINDOW_CLASS_NAME, m_Rainmeter->GetInstance());
|
||||
|
||||
if (c_DwmInstance)
|
||||
{
|
||||
@ -243,36 +245,19 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
|
||||
{
|
||||
m_Rainmeter = &Rainmeter;
|
||||
|
||||
// Register the windowclass
|
||||
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
|
||||
wc.style = CS_NOCLOSE | CS_DBLCLKS;
|
||||
wc.lpfnWndProc = InitialWndProc;
|
||||
wc.hInstance = m_Rainmeter->GetInstance();
|
||||
wc.hCursor = NULL; // The cursor should be controlled by using SetCursor() when needed.
|
||||
wc.lpszClassName = METERWINDOW_CLASS_NAME;
|
||||
|
||||
if (!RegisterClassEx(&wc))
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
|
||||
if (err != 0 && ERROR_CLASS_ALREADY_EXISTS != err)
|
||||
{
|
||||
throw CError(L"Unable to register class");
|
||||
}
|
||||
}
|
||||
|
||||
m_Window = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||
METERWINDOW_CLASS_NAME,
|
||||
NULL,
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
m_Rainmeter->GetInstance(),
|
||||
this);
|
||||
m_Window = CreateWindowEx(
|
||||
WS_EX_TOOLWINDOW,
|
||||
METERWINDOW_CLASS_NAME,
|
||||
NULL,
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
m_Rainmeter->GetInstance(),
|
||||
this);
|
||||
|
||||
if (m_Window == NULL)
|
||||
{
|
||||
@ -462,16 +447,10 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
// Start the timers
|
||||
if (m_WindowUpdate >= 0)
|
||||
{
|
||||
if (0 == SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL))
|
||||
{
|
||||
throw CError(L"Unable to set timer");
|
||||
}
|
||||
SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL);
|
||||
}
|
||||
|
||||
if (0 == SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, NULL)) // Mouse position is checked twice per sec
|
||||
{
|
||||
throw CError(L"Unable to set timer");
|
||||
}
|
||||
SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, NULL);
|
||||
|
||||
m_Rainmeter->SetCurrentParser(NULL);
|
||||
|
||||
|
@ -623,13 +623,8 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
if (m_CropMode < CROPMODE_TL || m_CropMode > CROPMODE_C)
|
||||
{
|
||||
std::wstring error = m_ConfigArray[ConfigIndexImageCrop];
|
||||
error += L'=';
|
||||
error += crop;
|
||||
error += L" (origin) is not valid in [";
|
||||
error += section;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
m_CropMode = CROPMODE_TL;
|
||||
LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_ConfigArray[ConfigIndexImageCrop], crop, section);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -731,13 +726,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = m_ConfigArray[ConfigIndexImageFlip];
|
||||
error += L'=';
|
||||
error += flip;
|
||||
error += L" is not valid in [";
|
||||
error += section;
|
||||
error += L']';
|
||||
throw CError(error);
|
||||
LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_ConfigArray[ConfigIndexImageFlip], flip, section);
|
||||
}
|
||||
|
||||
if (!m_DisableTransform)
|
||||
|
Loading…
Reference in New Issue
Block a user