From 2e32b0f5c15d6abd0bafd5abb47a299966fd02cd Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 6 Aug 2010 07:40:43 +0000 Subject: [PATCH] Some minor fixes. --- Library/MeterImage.cpp | 3 ++- Library/MeterWindow.cpp | 3 ++- Library/Rainmeter.cpp | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index b2caa344..0ef74858 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -408,7 +408,8 @@ void CMeterImage::ReadConfig(const WCHAR* section) m_Path = parser.ReadString(section, L"Path", L""); if (!m_Path.empty()) { - if (m_Path[m_Path.length() - 1] != L'\\') + WCHAR ch = m_Path[m_Path.length() - 1]; + if (ch != L'\\' && ch != L'/') { m_Path += L"\\"; } diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index af2825e9..74faccec 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -4377,7 +4377,8 @@ std::wstring CMeterWindow::MakePathAbsolute(std::wstring path) std::wstring root = m_SkinPath + m_SkinName; - if (root[root.length() - 1] != L'\\') + WCHAR ch = root[root.length() - 1]; + if (ch != L'\\' && ch != L'/') { root += L"\\"; } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index e0bad2d6..113174f0 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1368,9 +1368,13 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) m_PluginPath = ConvertToWide(tmpSz); } - if (!m_SkinPath.empty() && m_SkinPath[m_SkinPath.size() - 1] != L'\\') + if (!m_SkinPath.empty()) { - m_SkinPath += L"\\"; + WCHAR ch = m_SkinPath[m_SkinPath.size() - 1]; + if (ch != L'\\' && ch != L'/') + { + m_SkinPath += L"\\"; + } } } @@ -3106,6 +3110,11 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) } HMENU configMenu = CreateConfigMenu(m_ConfigMenu); + if (!configMenu) + { + configMenu = CreatePopupMenu(); + AppendMenu(configMenu, MF_GRAYED, 0, L"No configs available"); + } if (configMenu) { AppendMenu(configMenu, MF_SEPARATOR, 0, NULL); @@ -3655,12 +3664,12 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation) std::wstring CRainmeter::ExtractPath(const std::wstring& strFilePath) { - size_t pos = strFilePath.rfind(L"\\"); + std::wstring::size_type pos = strFilePath.find_last_of(L"\\/"); if (pos != std::wstring::npos) { return strFilePath.substr(0, pos + 1); } - return L"."; + return L".\\"; } void CRainmeter::ExpandEnvironmentVariables(std::wstring& strPath)