diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 258ab2ff..c82cff5b 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -3109,7 +3109,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_FadeStartTime == 0) { KillTimer(m_Window, TIMER_DEACTIVATE); - Rainmeter->DeleteMeterWindow(this); + Rainmeter->DeleteMeterWindow(this, true); } } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 0c406738..40ae14fd 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -243,8 +243,8 @@ void CRainmeter::BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfAr else { // No config defined -> apply to all. - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { ((*iter).second)->RunBang(bang, subStrings); } @@ -1036,8 +1036,8 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex) const std::wstring& skinConfig = m_ConfigStrings[configIndex].config; // Verify that the config is not already active - std::map::const_iterator iter = m_Meters.find(skinConfig); - if (iter != m_Meters.end()) + std::map::const_iterator iter = m_MeterWindows.find(skinConfig); + if (iter != m_MeterWindows.end()) { if (((*iter).second)->GetSkinIniFile() == skinIniFile) { @@ -1070,7 +1070,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex) } } -bool CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save) +void CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save) { if (configIndex >= 0 && configIndex < (int)m_ConfigStrings.size()) { @@ -1100,7 +1100,6 @@ bool CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bo meterWindow->Deactivate(); } - return false; } void CRainmeter::ToggleConfig(int configIndex, int iniIndex) @@ -1133,7 +1132,7 @@ void CRainmeter::CreateMeterWindow(const std::wstring& config, const std::wstrin if (mw) { - m_Meters[config] = mw; + m_MeterWindows[config] = mw; try { @@ -1150,10 +1149,10 @@ void CRainmeter::CreateMeterWindow(const std::wstring& config, const std::wstrin } } -bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow) +void CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool force) { - std::map::iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { if (meterWindow == NULL) { @@ -1163,26 +1162,27 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow) } else if ((*iter).second == meterWindow) { - m_Meters.erase(iter); + m_MeterWindows.erase(iter); delete meterWindow; - - return true; + return; } } if (meterWindow == NULL) { - m_Meters.clear(); + m_MeterWindows.clear(); + } + else if (force) + { + delete meterWindow; } - - return false; } CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& config) { const WCHAR* configName = config.c_str(); - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { if (_wcsicmp((*iter).first.c_str(), configName) == 0) { @@ -1199,8 +1199,8 @@ CMeterWindow* CRainmeter::GetMeterWindowByINI(const std::wstring& ini_searching) { const std::wstring config_searching = ini_searching.substr(m_SkinPath.length()); - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { std::wstring config_current = (*iter).second->GetSkinName() + L'\\'; config_current += (*iter).second->GetSkinIniFile(); @@ -1266,8 +1266,8 @@ std::pair CRainmeter::GetMeterWindowIndex(UINT menuCommand) CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd) { - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { if ((*iter).second->GetWindow() == hwnd) { @@ -1280,8 +1280,8 @@ CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd) void CRainmeter::GetMeterWindowsByLoadOrder(std::multimap& windows, const std::wstring& group) { - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { CMeterWindow* mw = (*iter).second; if (mw && (group.empty() || mw->BelongsToGroup(group))) @@ -2464,8 +2464,8 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) // Create a menu for all active configs int index = 0; - std::map::const_iterator iter = m_Meters.begin(); - for (; iter != m_Meters.end(); ++iter) + std::map::const_iterator iter = m_MeterWindows.begin(); + for (; iter != m_MeterWindows.end(); ++iter) { CMeterWindow* mw = ((*iter).second); HMENU skinMenu = CreateSkinMenu(mw, index, configMenu); diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index cf6166b5..fc16d8f2 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -129,14 +129,14 @@ public: CMeterWindow* GetMeterWindow(HWND hwnd); void GetMeterWindowsByLoadOrder(std::multimap& windows, const std::wstring& group = std::wstring()); - std::map& GetAllMeterWindows() { return m_Meters; } + std::map& GetAllMeterWindows() { return m_MeterWindows; } const std::vector& GetAllConfigs() { return m_ConfigStrings; } const std::vector& GetAllThemes() { return m_Themes; } - bool DeleteMeterWindow(CMeterWindow* meterWindow); + void DeleteMeterWindow(CMeterWindow* meterWindow, bool force = false); void ActivateConfig(int configIndex, int iniIndex); - bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save = true); + void DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save = true); void ToggleConfig(int configIndex, int iniIndex); const std::wstring& GetPath() { return m_Path; } @@ -251,7 +251,7 @@ private: std::vector m_ConfigStrings; // All configs found in the given folder std::vector m_ConfigMenu; std::multimap m_ConfigOrders; - std::map m_Meters; // The meter windows + std::map m_MeterWindows; std::vector m_Themes; std::wstring m_Path; // Path to the main folder