diff --git a/idd/LGCommon/CDebug.cpp b/idd/LGCommon/CDebug.cpp index 31a72605..b5497407 100644 --- a/idd/LGCommon/CDebug.cpp +++ b/idd/LGCommon/CDebug.cpp @@ -101,7 +101,7 @@ inline static void iso8601(wchar_t *buf, size_t count) wcsftime(buf, count, L"%Y-%m-%d %H:%M:%SZ", &utc); } -inline static std::wstring getLogPath(CDebug::Location location) +std::wstring CDebug::GetLogDir(Location location) { PWSTR pszPath; const KNOWNFOLDERID& folder = location == CDebug::Location::LocalAppData ? @@ -133,7 +133,7 @@ inline static std::wstring getLogPath(CDebug::Location location) void CDebug::Init(const wchar_t * name, Location location) { - m_logDir = getLogPath(location); + m_logDir = GetLogDir(location); // don't redirect the debug output if running under a debugger if (IsDebuggerPresent()) diff --git a/idd/LGCommon/CDebug.h b/idd/LGCommon/CDebug.h index 095cdab3..7b12df65 100644 --- a/idd/LGCommon/CDebug.h +++ b/idd/LGCommon/CDebug.h @@ -22,6 +22,7 @@ #include #include +#include class CDebug { @@ -51,7 +52,8 @@ class CDebug LEVEL_MAX }; - const wchar_t *logDir() { return m_logDir.c_str(); } + const wchar_t *logDir() const { return m_logDir.c_str(); } + static std::wstring GetLogDir(Location location); void Init(const wchar_t * name, Location location = Location::ProgramData); void Log_va(CDebug::Level level, const char *function, int line, const wchar_t *fmt, va_list args); diff --git a/idd/LGIddHelper/CNotifyWindow.cpp b/idd/LGIddHelper/CNotifyWindow.cpp index 038b7563..f6b69be2 100644 --- a/idd/LGIddHelper/CNotifyWindow.cpp +++ b/idd/LGIddHelper/CNotifyWindow.cpp @@ -196,8 +196,13 @@ LRESULT CNotifyWindow::onNotifyIcon(UINT uEvent, WORD wIconId, int x, int y) switch (TrackPopupMenu(m_menu, TPM_RETURNCMD | TPM_NONOTIFY, x, y, 0, m_hwnd, NULL)) { case ID_MENU_SHOW_LOG: - ShellExecute(m_hwnd, L"open", g_debug.logDir(), NULL, NULL, SW_NORMAL); + { + const std::wstring logDir = + CDebug::GetLogDir(CDebug::Location::ProgramData); + if (!logDir.empty()) + ShellExecute(m_hwnd, L"open", logDir.c_str(), NULL, NULL, SW_NORMAL); break; + } case ID_MENU_SHOW_CONFIG: DEBUG_INFO("Config window opened"); m_config.reset(new CConfigWindow());