From b5042589cb936ba7182c6f087d9c857b17b32530 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Sun, 18 Oct 2009 13:31:55 +0000 Subject: [PATCH] The deactivated window wasn't deleted properly (issue 117). Deactivating a config kept it still activate in the rainmeter.ini file (issue 118). --- Library/MeterWindow.h | 2 +- Library/Rainmeter.cpp | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index ccdedd64..0c9929af 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -141,6 +141,7 @@ public: void MoveWindow(int x, int y); void ChangeZPos(ZPOSITION zPos); + void FadeWindow(int from, int to); Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; }; HWND GetWindow() { return m_Window; }; @@ -222,7 +223,6 @@ private: void ShowWindowIfAppropriate(); bool DoAction(int x, int y, MOUSE mouse, bool test); bool ResizeWindow(bool reset); - void FadeWindow(int from, int to); CConfigParser m_Parser; diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index b4c2e69f..b5bafc52 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1180,10 +1180,10 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex) { m_ConfigStrings[configIndex].active = iniIndex + 1; - CreateMeterWindow(skinPath, skinConfig, skinIniFile); - wsprintf(buffer, L"%i", iniIndex + 1); WritePrivateProfileString(skinConfig.c_str(), L"Active", buffer, m_IniFile.c_str()); + + CreateMeterWindow(skinPath, skinConfig, skinIniFile); } catch(CError& error) { @@ -1232,7 +1232,22 @@ void CRainmeter::ClearDeleteLaterList() { while (!m_DelayDeleteList.empty()) { - DeleteMeterWindow(m_DelayDeleteList.front(), false); + CMeterWindow* meterWindow = m_DelayDeleteList.front(); + delete meterWindow; + + // Remove from the delete later list + m_DelayDeleteList.remove(meterWindow); + + // Remove from the meter window list if it is still there + std::map::iterator iter = m_Meters.begin(); + for (; iter != m_Meters.end(); iter++) + { + if ((*iter).second == meterWindow) + { + m_Meters.erase(iter); + break; + } + } } } @@ -1241,6 +1256,7 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater) if (bLater) { m_DelayDeleteList.push_back(meterWindow); + meterWindow->FadeWindow(meterWindow->GetAlphaValue(), 0); // Fade out the window } else {