Fix crash when actions are executed by plugin threads after skin unload

This commit is contained in:
Birunthan Mohanathas 2013-03-21 14:29:59 +02:00
parent b7c1e16554
commit 9bf5871abf
3 changed files with 20 additions and 14 deletions

View File

@ -4677,19 +4677,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (pCopyDataStruct && (pCopyDataStruct->dwData == 1) && (pCopyDataStruct->cbData > 0)) if (pCopyDataStruct && (pCopyDataStruct->dwData == 1) && (pCopyDataStruct->cbData > 0))
{ {
// Check that we're still alive if (Rainmeter->HasMeterWindow(this))
bool found = false;
std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
{
if ((*iter).second == this)
{
found = true;
break;
}
}
if (found)
{ {
const WCHAR* command = (const WCHAR*)pCopyDataStruct->lpData; const WCHAR* command = (const WCHAR*)pCopyDataStruct->lpData;
Rainmeter->ExecuteCommand(command, this); Rainmeter->ExecuteCommand(command, this);

View File

@ -1172,7 +1172,10 @@ LRESULT CALLBACK CRainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
break; break;
case WM_RAINMETER_EXECUTE: case WM_RAINMETER_EXECUTE:
Rainmeter->ExecuteCommand((const WCHAR*)lParam, (CMeterWindow*)wParam); if (Rainmeter->HasMeterWindow((CMeterWindow*)wParam))
{
Rainmeter->ExecuteCommand((const WCHAR*)lParam, (CMeterWindow*)wParam);
}
break; break;
default: default:
@ -1598,6 +1601,19 @@ void CRainmeter::RemoveUnmanagedMeterWindow(CMeterWindow* meterWindow)
} }
} }
bool CRainmeter::HasMeterWindow(const CMeterWindow* meterWindow) const
{
for (auto it = m_MeterWindows.begin(); it != m_MeterWindows.end(); ++it)
{
if ((*it).second == meterWindow)
{
return true;
}
}
return false;
}
CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& folderPath) CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& folderPath)
{ {
const WCHAR* folderSz = folderPath.c_str(); const WCHAR* folderSz = folderPath.c_str();

View File

@ -110,6 +110,8 @@ public:
CTrayWindow* GetTrayWindow() { return m_TrayWindow; } CTrayWindow* GetTrayWindow() { return m_TrayWindow; }
bool HasMeterWindow(const CMeterWindow* meterWindow) const;
CMeterWindow* GetMeterWindow(const std::wstring& folderPath); CMeterWindow* GetMeterWindow(const std::wstring& folderPath);
CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching); CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching);
std::pair<int, int> GetMeterWindowIndex(const std::wstring& folderPath, const std::wstring& file); std::pair<int, int> GetMeterWindowIndex(const std::wstring& folderPath, const std::wstring& file);