Fixed crash that could occur when using RmExecute from separate thread (in WebParser)

This commit is contained in:
Birunthan Mohanathas 2012-02-22 06:42:52 +00:00
parent bb865ec514
commit b60d7bdd90
6 changed files with 14 additions and 9 deletions

View File

@ -90,7 +90,8 @@ void __stdcall RmExecute(void* skin, LPCWSTR command)
CMeterWindow* mw = (CMeterWindow*)skin;
if (command)
{
Rainmeter->ExecuteCommand(command, mw);
// WM_RAINMETER_EXECUTE used instead of ExecuteCommand for thread-safety
SendMessage(Rainmeter->GetWindow(), WM_RAINMETER_EXECUTE, (WPARAM)mw, (LPARAM)command);
}
}

View File

@ -700,7 +700,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const std::vector<std::wstring>& ar
{
case BANG_REFRESH:
// Refresh needs to be delayed since it crashes if done during Update()
PostMessage(m_Window, WM_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL);
PostMessage(m_Window, WM_METERWINDOW_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL);
break;
case BANG_REDRAW:
@ -4638,8 +4638,8 @@ LRESULT CALLBACK CMeterWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
MESSAGE(OnMiddleButtonDoubleClick, WM_NCMBUTTONDBLCLK)
MESSAGE(OnWindowPosChanging, WM_WINDOWPOSCHANGING)
MESSAGE(OnCopyData, WM_COPYDATA)
MESSAGE(OnDelayedRefresh, WM_DELAYED_REFRESH)
MESSAGE(OnDelayedMove, WM_DELAYED_MOVE)
MESSAGE(OnDelayedRefresh, WM_METERWINDOW_DELAYED_REFRESH)
MESSAGE(OnDelayedMove, WM_METERWINDOW_DELAYED_MOVE)
MESSAGE(OnDwmColorChange, WM_DWMCOLORIZATIONCOLORCHANGED)
MESSAGE(OnDwmCompositionChange, WM_DWMCOMPOSITIONCHANGED)
MESSAGE(OnSettingChange, WM_SETTINGCHANGE)
@ -4706,7 +4706,7 @@ LRESULT CMeterWindow::OnDelayedMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
else
{
// With copy transparency we'll do a full refresh
PostMessage(m_Window, WM_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL);
PostMessage(m_Window, WM_METERWINDOW_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL);
}
return 0;

View File

@ -32,8 +32,8 @@
#define REJECT_MESSAGE(msg) case msg: return 0;
#define END_MESSAGEPROC } return DefWindowProc(hWnd, uMsg, wParam, lParam);
#define WM_DELAYED_REFRESH WM_APP + 1
#define WM_DELAYED_MOVE WM_APP + 3
#define WM_METERWINDOW_DELAYED_REFRESH WM_APP + 1
#define WM_METERWINDOW_DELAYED_MOVE WM_APP + 3
#define METERWINDOW_CLASS_NAME L"RainmeterMeterWindow"

View File

@ -1102,6 +1102,10 @@ LRESULT CALLBACK CRainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
}
break;
case WM_RAINMETER_EXECUTE:
Rainmeter->ExecuteCommand((const WCHAR*)lParam, (CMeterWindow*)wParam);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@ -2090,7 +2094,6 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
}
}
/*
** Executes command when current processing is done.
**

View File

@ -44,6 +44,7 @@
#define WM_RAINMETER_DELAYED_REFRESH_ALL WM_APP + 0
#define WM_RAINMETER_DELAYED_EXECUTE WM_APP + 1
#define WM_RAINMETER_EXECUTE WM_APP + 2
struct GlobalConfig
{

View File

@ -1009,7 +1009,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
{
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
PostMessage((*iter).second->GetWindow(), WM_METERWINDOW_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
}
}
break;