mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Additional changes to af8befd
: Fixed that unloaded skin is not deleted properly in rare case.
This commit is contained in:
parent
27fe4a1e1c
commit
6ad5d56498
@ -394,6 +394,7 @@ void CMeterWindow::Deactivate()
|
||||
m_State = STATE_CLOSING;
|
||||
|
||||
Rainmeter->RemoveMeterWindow(this);
|
||||
Rainmeter->AddUnmanagedMeterWindow(this);
|
||||
|
||||
HideFade();
|
||||
SetTimer(m_Window, TIMER_DEACTIVATE, m_FadeDuration + 50, NULL);
|
||||
@ -2887,6 +2888,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
if (m_FadeStartTime == 0)
|
||||
{
|
||||
KillTimer(m_Window, TIMER_DEACTIVATE);
|
||||
Rainmeter->RemoveUnmanagedMeterWindow(this);
|
||||
delete this;
|
||||
}
|
||||
break;
|
||||
|
@ -728,6 +728,7 @@ CRainmeter::~CRainmeter()
|
||||
{
|
||||
KillTimer(m_Window, TIMER_NETSTATS);
|
||||
|
||||
DeleteAllUnmanagedMeterWindows();
|
||||
DeleteAllMeterWindows();
|
||||
|
||||
delete m_TrayWindow;
|
||||
@ -1540,8 +1541,18 @@ void CRainmeter::DeleteAllMeterWindows()
|
||||
CDialogAbout::UpdateSkins();
|
||||
}
|
||||
|
||||
void CRainmeter::DeleteAllUnmanagedMeterWindows()
|
||||
{
|
||||
for (auto it = m_UnmanagedMeterWindows.cbegin(); it != m_UnmanagedMeterWindows.end(); ++it)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
m_UnmanagedMeterWindows.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
** Removes the skin from m_MeterWindow. The skin should delete itself.
|
||||
** Removes the skin from m_MeterWindows. The skin should delete itself.
|
||||
**
|
||||
*/
|
||||
void CRainmeter::RemoveMeterWindow(CMeterWindow* meterWindow)
|
||||
@ -1558,6 +1569,35 @@ void CRainmeter::RemoveMeterWindow(CMeterWindow* meterWindow)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Adds the skin to m_UnmanagedMeterWindows. The skin should remove itself by calling RemoveUnmanagedMeterWindow().
|
||||
**
|
||||
*/
|
||||
void CRainmeter::AddUnmanagedMeterWindow(CMeterWindow* meterWindow)
|
||||
{
|
||||
for (auto it = m_UnmanagedMeterWindows.cbegin(); it != m_UnmanagedMeterWindows.cend(); ++it)
|
||||
{
|
||||
if ((*it) == meterWindow) // already added
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_UnmanagedMeterWindows.push_back(meterWindow);
|
||||
}
|
||||
|
||||
void CRainmeter::RemoveUnmanagedMeterWindow(CMeterWindow* meterWindow)
|
||||
{
|
||||
for (auto it = m_UnmanagedMeterWindows.cbegin(); it != m_UnmanagedMeterWindows.cend(); ++it)
|
||||
{
|
||||
if ((*it) == meterWindow)
|
||||
{
|
||||
m_UnmanagedMeterWindows.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& folderPath)
|
||||
{
|
||||
const WCHAR* folderSz = folderPath.c_str();
|
||||
@ -2590,6 +2630,7 @@ bool CRainmeter::LoadLayout(const std::wstring& name)
|
||||
return false;
|
||||
}
|
||||
|
||||
DeleteAllUnmanagedMeterWindows();
|
||||
DeleteAllMeterWindows();
|
||||
|
||||
std::wstring backup = GetLayoutPath();
|
||||
|
@ -126,8 +126,9 @@ public:
|
||||
const std::vector<SkinFolder>& GetFolders() { return m_SkinFolders; }
|
||||
const std::vector<std::wstring>& GetAllLayouts() { return m_Layouts; }
|
||||
|
||||
void DeleteAllMeterWindows();
|
||||
void RemoveMeterWindow(CMeterWindow* meterWindow);
|
||||
void AddUnmanagedMeterWindow(CMeterWindow* meterWindow);
|
||||
void RemoveUnmanagedMeterWindow(CMeterWindow* meterWindow);
|
||||
|
||||
void ActivateSkin(int folderIndex, int fileIndex);
|
||||
void DeactivateSkin(CMeterWindow* meterWindow, int folderIndex, bool save = true);
|
||||
@ -246,6 +247,8 @@ private:
|
||||
|
||||
void ActivateActiveSkins();
|
||||
void CreateMeterWindow(const std::wstring& folderPath, const std::wstring& file);
|
||||
void DeleteAllMeterWindows();
|
||||
void DeleteAllUnmanagedMeterWindows();
|
||||
void WriteActive(const std::wstring& folderPath, int fileIndex);
|
||||
void ScanForSkins();
|
||||
void ScanForLayouts();
|
||||
@ -273,6 +276,7 @@ private:
|
||||
std::vector<SkinFolder> m_SkinFolders;
|
||||
std::multimap<int, int> m_SkinOrders;
|
||||
std::map<std::wstring, CMeterWindow*> m_MeterWindows;
|
||||
std::list<CMeterWindow*> m_UnmanagedMeterWindows;
|
||||
std::vector<std::wstring> m_Layouts;
|
||||
|
||||
std::wstring m_Path;
|
||||
|
Loading…
Reference in New Issue
Block a user