diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 5208ba9d..eb2e8684 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -93,17 +93,23 @@ void CDialogAbout::Open(int tab) c_Dialog->OnNotify(0, (LPARAM)&nm); } -void CDialogAbout::AddLogItem(int level, LPCWSTR time, LPCWSTR message) +/* +** ShowAboutLog +** +** Shows log if dialog isn't already open. +** +*/ +void CDialogAbout::ShowAboutLog() { if (!c_Dialog) { - if (level == LOG_ERROR) - { - // Open About Log window for errors - CDialogAbout::Open(); - } + Open(); } - else if (c_Dialog->m_TabLog && c_Dialog->m_TabLog->IsInitialized()) +} + +void CDialogAbout::AddLogItem(int level, LPCWSTR time, LPCWSTR message) +{ + if (c_Dialog && c_Dialog->m_TabLog && c_Dialog->m_TabLog->IsInitialized()) { c_Dialog->m_TabLog->AddItem(level, time, message); } diff --git a/Library/DialogAbout.h b/Library/DialogAbout.h index ee3dc303..e0e1c784 100644 --- a/Library/DialogAbout.h +++ b/Library/DialogAbout.h @@ -35,6 +35,7 @@ public: INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); static void Open(int tab = 0); + static void ShowAboutLog(); static void AddLogItem(int level, LPCWSTR time, LPCWSTR message); static void UpdateSkins(); diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 6ea53c7b..b0fe9844 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -18,8 +18,8 @@ #include "StdAfx.h" #include "Litestep.h" -#include "Error.h" #include "Rainmeter.h" +#include "DialogAbout.h" #include "System.h" extern CRainmeter* Rainmeter; @@ -719,6 +719,12 @@ void LogWithArgs(int nLevel, const WCHAR* format, ... ) delete [] buffer; } +void LogError(CError& error) +{ + Log(LOG_ERROR, error.GetString().c_str()); + CDialogAbout::ShowAboutLog(); +} + void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) { // Do nothing. diff --git a/Library/Litestep.h b/Library/Litestep.h index 857da37e..8837edd4 100644 --- a/Library/Litestep.h +++ b/Library/Litestep.h @@ -22,6 +22,7 @@ #include #include #include +#include "Error.h" #include "Export.h" #define magicDWord 0x49474541 @@ -52,6 +53,7 @@ void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* void Log(int nLevel, const WCHAR* message, const WCHAR* module = L"Rainmeter"); // Wrapper for LSLog(). void LogWithArgs(int nLevel, const WCHAR* format, ... ); // Replacement for DebugLog(), has the same functionality but has the option to set teh Log Level. +void LogError(CError& error); void ResetLoggingFlag(); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 780f0166..1f9d2081 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2315,7 +2315,7 @@ bool CMeterWindow::ReadSkin() { delete measure; measure = NULL; - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } else if (meterName.length() > 0) @@ -2345,7 +2345,7 @@ bool CMeterWindow::ReadSkin() { delete meter; meter = NULL; - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } // If it's not a meter or measure it will be ignored @@ -2384,7 +2384,7 @@ bool CMeterWindow::ReadSkin() } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } } @@ -2410,7 +2410,7 @@ void CMeterWindow::InitializeMeasures() } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } } @@ -2433,7 +2433,7 @@ void CMeterWindow::InitializeMeters() } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } if (!(*j)->GetToolTipText().empty()) @@ -2897,7 +2897,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force) } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } @@ -2937,7 +2937,7 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } @@ -3828,7 +3828,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } return 0; @@ -5024,7 +5024,7 @@ LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam) } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } return 0; } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index bba3724c..5e78afe1 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -2248,7 +2248,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex) } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } } @@ -3562,7 +3562,7 @@ void CRainmeter::RefreshAll() } catch (CError& error) { - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } } } diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 5ca4dd3b..bf35754b 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -315,7 +315,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser) { delete m_Measure; m_Measure = NULL; - Log(LOG_ERROR, error.GetString().c_str()); + LogError(error); } Rainmeter->SetCurrentParser(oldParser);