Fix that unloaded skin is displayed in context menu until fade is complete

This commit is contained in:
Birunthan Mohanathas 2013-03-10 12:14:40 +02:00
parent 3552a928dd
commit af8befd22b
3 changed files with 29 additions and 29 deletions

View File

@ -389,6 +389,8 @@ void CMeterWindow::RemoveWindowExStyle(LONG_PTR flag)
*/ */
void CMeterWindow::Deactivate() void CMeterWindow::Deactivate()
{ {
Rainmeter->RemoveMeterWindow(this);
HideFade(); HideFade();
SetTimer(m_Window, TIMER_DEACTIVATE, m_FadeDuration + 50, NULL); SetTimer(m_Window, TIMER_DEACTIVATE, m_FadeDuration + 50, NULL);
} }
@ -2879,7 +2881,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_FadeStartTime == 0) if (m_FadeStartTime == 0)
{ {
KillTimer(m_Window, TIMER_DEACTIVATE); KillTimer(m_Window, TIMER_DEACTIVATE);
Rainmeter->DeleteMeterWindow(this, true); // "delete this;" delete this;
} }
break; break;
} }

View File

@ -728,7 +728,7 @@ CRainmeter::~CRainmeter()
{ {
KillTimer(m_Window, TIMER_NETSTATS); KillTimer(m_Window, TIMER_NETSTATS);
DeleteMeterWindow(NULL); DeleteAllMeterWindows();
delete m_TrayWindow; delete m_TrayWindow;
@ -1528,36 +1528,34 @@ void CRainmeter::CreateMeterWindow(const std::wstring& folderPath, const std::ws
CDialogManage::UpdateSkins(mw); CDialogManage::UpdateSkins(mw);
} }
void CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool force) void CRainmeter::DeleteAllMeterWindows()
{ {
std::map<std::wstring, CMeterWindow*>::iterator iter = m_MeterWindows.begin(); for (auto it = m_MeterWindows.cbegin(); it != m_MeterWindows.end(); ++it)
for (; iter != m_MeterWindows.end(); ++iter)
{ {
if (meterWindow == NULL) CDialogManage::UpdateSkins((*it).second, true);
{ delete (*it).second;
// Delete all meter windows
CDialogManage::UpdateSkins((*iter).second, true);
delete (*iter).second;
} }
else if ((*iter).second == meterWindow)
m_MeterWindows.clear();
CDialogAbout::UpdateSkins();
}
/*
** Removes the skin from m_MeterWindow. The skin should delete itself.
**
*/
void CRainmeter::RemoveMeterWindow(CMeterWindow* meterWindow)
{ {
m_MeterWindows.erase(iter); for (auto it = m_MeterWindows.cbegin(); it != m_MeterWindows.end(); ++it)
force = true; {
if ((*it).second == meterWindow)
{
m_MeterWindows.erase(it);
CDialogManage::UpdateSkins(meterWindow, true);
CDialogAbout::UpdateSkins();
break; break;
} }
} }
if (meterWindow == NULL)
{
m_MeterWindows.clear();
}
else if (force)
{
CDialogManage::UpdateSkins(meterWindow, true);
delete meterWindow;
}
CDialogAbout::UpdateSkins();
} }
CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& folderPath) CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& folderPath)
@ -2592,8 +2590,7 @@ bool CRainmeter::LoadLayout(const std::wstring& name)
return false; return false;
} }
// Delete all meter windows DeleteAllMeterWindows();
DeleteMeterWindow(NULL);
std::wstring backup = GetLayoutPath(); std::wstring backup = GetLayoutPath();
backup += L"@Backup"; backup += L"@Backup";

View File

@ -126,7 +126,8 @@ public:
const std::vector<SkinFolder>& GetFolders() { return m_SkinFolders; } const std::vector<SkinFolder>& GetFolders() { return m_SkinFolders; }
const std::vector<std::wstring>& GetAllLayouts() { return m_Layouts; } const std::vector<std::wstring>& GetAllLayouts() { return m_Layouts; }
void DeleteMeterWindow(CMeterWindow* meterWindow, bool force = false); void DeleteAllMeterWindows();
void RemoveMeterWindow(CMeterWindow* meterWindow);
void ActivateSkin(int folderIndex, int fileIndex); void ActivateSkin(int folderIndex, int fileIndex);
void DeactivateSkin(CMeterWindow* meterWindow, int folderIndex, bool save = true); void DeactivateSkin(CMeterWindow* meterWindow, int folderIndex, bool save = true);