The window deletion is now delayed when !RainmeterDeactivateConfig is used. This fixes the problem: Issue 116: Crash when skin tries to deactivate self by measure action.

This commit is contained in:
Kimmo Pekkola 2009-10-17 06:43:18 +00:00
parent a5b6d3a46e
commit 2c6c43c652
4 changed files with 44 additions and 21 deletions

View File

@ -2149,6 +2149,8 @@ LRESULT CMeterWindow::OnTimer(WPARAM wParam, LPARAM lParam)
// MoveWindow(x, y); // MoveWindow(x, y);
// } // }
//} //}
Rainmeter->ClearDeleteLaterList();
} }
else if(wParam == TRANSITIONTIMER) else if(wParam == TRANSITIONTIMER)
{ {

View File

@ -648,7 +648,7 @@ CRainmeter::~CRainmeter()
while (m_Meters.size() > 0) while (m_Meters.size() > 0)
{ {
DeleteMeterWindow((*m_Meters.begin()).second); // This removes the window from the vector DeleteMeterWindow((*m_Meters.begin()).second, false); // This removes the window from the vector
} }
if (m_TrayWindow) delete m_TrayWindow; if (m_TrayWindow) delete m_TrayWindow;
@ -1203,7 +1203,7 @@ bool CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex)
// Disable the config in the ini-file // Disable the config in the ini-file
WritePrivateProfileString(meterWindow->GetSkinName().c_str(), L"Active", L"0", m_IniFile.c_str()); WritePrivateProfileString(meterWindow->GetSkinName().c_str(), L"Active", L"0", m_IniFile.c_str());
return DeleteMeterWindow(meterWindow); return DeleteMeterWindow(meterWindow, true);
} }
return false; return false;
} }
@ -1219,8 +1219,24 @@ void CRainmeter::CreateMeterWindow(std::wstring path, std::wstring config, std::
} }
} }
bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow) void CRainmeter::ClearDeleteLaterList()
{ {
while (!m_DelayDeleteList.empty())
{
DeleteMeterWindow(m_DelayDeleteList.front(), false);
}
}
bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater)
{
if (bLater)
{
m_DelayDeleteList.push_back(meterWindow);
}
else
{
m_DelayDeleteList.remove(meterWindow); // Remove the window from the delete later list if it is there
std::map<std::wstring, CMeterWindow*>::iterator iter = m_Meters.begin(); std::map<std::wstring, CMeterWindow*>::iterator iter = m_Meters.begin();
for (; iter != m_Meters.end(); iter++) for (; iter != m_Meters.end(); iter++)
@ -1242,6 +1258,7 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow)
{ {
m_Meters.clear(); m_Meters.clear();
} }
}
return false; return false;
} }

View File

@ -161,13 +161,15 @@ public:
std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow); std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow);
void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow); void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow);
void ClearDeleteLaterList();
static PLATFORM IsNT(); static PLATFORM IsNT();
static std::wstring ExtractPath(const std::wstring& strFilePath); static std::wstring ExtractPath(const std::wstring& strFilePath);
static void ExpandEnvironmentVariables(std::wstring& strPath); static void ExpandEnvironmentVariables(std::wstring& strPath);
private: private:
void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile); void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile);
bool DeleteMeterWindow(CMeterWindow* meterWindow); bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater);
void ScanForConfigs(std::wstring& path); void ScanForConfigs(std::wstring& path);
void ScanForThemes(std::wstring& path); void ScanForThemes(std::wstring& path);
void ReadGeneralSettings(std::wstring& path); void ReadGeneralSettings(std::wstring& path);
@ -219,6 +221,8 @@ private:
ULONG_PTR m_GDIplusToken; ULONG_PTR m_GDIplusToken;
std::list<CMeterWindow*> m_DelayDeleteList;
static bool c_DummyLitestep; // true, if not a Litestep plugin static bool c_DummyLitestep; // true, if not a Litestep plugin
static std::wstring c_CmdLine; // The command line arguments static std::wstring c_CmdLine; // The command line arguments
static GlobalConfig c_GlobalConfig; static GlobalConfig c_GlobalConfig;

View File

@ -1,2 +1,2 @@
#pragma once #pragma once
const int revision_number = 223; const int revision_number = 256;