From 40f11d3934058f053a290585a5d8ed589cb87b99 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Wed, 19 Aug 2009 17:57:09 +0000 Subject: [PATCH] !RainmeterRefresh and !RainmeterQuit are now handled only during the event loop since they can crash the application if executed during Update(). --- Library/MeterWindow.cpp | 33 ++++++++++++++++++++++++++++++--- Library/MeterWindow.h | 6 +++++- revision-number.h | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 44db887d..140d8438 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -509,7 +509,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) switch(bang) { case BANG_REFRESH: - Refresh(false); + // Refresh needs to be delayed since it crashes if done during Update() + PostMessage(m_Window, WM_DELAYED_REFRESH, (WPARAM)NULL, (LPARAM)NULL); break; case BANG_REDRAW: @@ -670,8 +671,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) break; case BANG_QUIT: - if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0); - quitModule(Rainmeter->GetInstance()); + // Quit needs to be delayed since it crashes if done during Update() + PostMessage(m_Window, WM_DELAYED_QUIT, (WPARAM)NULL, (LPARAM)NULL); break; } } @@ -3088,6 +3089,8 @@ LRESULT CALLBACK CMeterWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR MESSAGE(OnWindowPosChanging, WM_WINDOWPOSCHANGING) MESSAGE(OnCopyData, WM_COPYDATA) MESSAGE(OnDelayedExecute, WM_DELAYED_EXECUTE) + MESSAGE(OnDelayedRefresh, WM_DELAYED_REFRESH) + MESSAGE(OnDelayedQuit, WM_DELAYED_QUIT) MESSAGE(OnSettingChange, WM_SETTINGCHANGE) END_MESSAGEPROC } @@ -3114,6 +3117,30 @@ LRESULT CMeterWindow::OnDelayedExecute(WPARAM wParam, LPARAM lParam) return 0; } +/* +** OnDelayedRefresh +** +** Handles delayed refresh +** +*/ +LRESULT CMeterWindow::OnDelayedRefresh(WPARAM wParam, LPARAM lParam) +{ + Refresh(false); + return 0; +} + +/* +** OnDelayedQuit +** +** Handles delayed quit +** +*/ +LRESULT CMeterWindow::OnDelayedQuit(WPARAM wParam, LPARAM lParam) +{ + if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0); + quitModule(Rainmeter->GetInstance()); + return 0; +} /* ** OnCopyData diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 540b991b..251fdf74 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -34,7 +34,9 @@ #define REJECT_MESSAGE(msg) case msg: return 0; #define END_MESSAGEPROC } return DefWindowProc(hWnd, uMsg, wParam, lParam); -#define WM_DELAYED_EXECUTE WM_APP +#define WM_DELAYED_EXECUTE WM_APP + 0 +#define WM_DELAYED_REFRESH WM_APP + 1 +#define WM_DELAYED_QUIT WM_APP + 2 enum MOUSE { @@ -191,6 +193,8 @@ protected: LRESULT OnLeftButtonUp(WPARAM wParam, LPARAM lParam); LRESULT OnRightButtonUp(WPARAM wParam, LPARAM lParam); LRESULT OnDelayedExecute(WPARAM wParam, LPARAM lParam); + LRESULT OnDelayedRefresh(WPARAM wParam, LPARAM lParam); + LRESULT OnDelayedQuit(WPARAM wParam, LPARAM lParam); LRESULT OnSettingChange(WPARAM wParam, LPARAM lParam); diff --git a/revision-number.h b/revision-number.h index d00e65c1..da1758ec 100644 --- a/revision-number.h +++ b/revision-number.h @@ -1,2 +1,2 @@ #pragma once -const int revision_number = 181; \ No newline at end of file +const int revision_number = 185; \ No newline at end of file