Commit 4b48ad5d authored by Erwan Tulou's avatar Erwan Tulou

skins2(Win): fix sporadic crash

Timer messages may be pending and must be explicitely discarded
when calling the destructor of a timer. Otherwise, the callback
function is called after the object is destroyed leading to crash.

(cherry picked from commit 90cb142c)
Signed-off-by: default avatarErwan Tulou <>
parent 554c7b54
......@@ -33,10 +33,7 @@ void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
(void)hwnd; (void)uMsg; (void)dwTime;
Win32Timer *pTimer = (Win32Timer*)idEvent;
if( pTimer != NULL )
......@@ -49,6 +46,15 @@ Win32Timer::Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd ):
// discard possible WM_TIMER messages for this timer
// already in the message queue and not yet dispatched
MSG msg;
while( !PeekMessage( &msg, m_hWnd, WM_TIMER, WM_TIMER, PM_REMOVE ) )
if( (Win32Timer*)msg.wParam != this )
PostMessage( m_hWnd, WM_TIMER, msg.wParam, msg.lParam );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment