From: Rémi Bernon rbernon@codeweavers.com
Instead of interrupting the wait on any message. --- dlls/joy.cpl/dinput.c | 11 ++++++++++- dlls/joy.cpl/xinput.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index 521634ff7da..9762dd4b435 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -792,7 +792,16 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM case PSN_RESET: case PSN_KILLACTIVE: SetEvent( thread_stop ); - MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, 0 ); + /* wait for the input thread to stop, processing any WM_USER message from it */ + while (MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, QS_ALLINPUT )) + { + MSG msg; + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } + } CloseHandle( state_event ); CloseHandle( thread_stop ); CloseHandle( thread ); diff --git a/dlls/joy.cpl/xinput.c b/dlls/joy.cpl/xinput.c index 757b99fa333..8459ab0be42 100644 --- a/dlls/joy.cpl/xinput.c +++ b/dlls/joy.cpl/xinput.c @@ -428,7 +428,16 @@ extern INT_PTR CALLBACK test_xi_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, case PSN_RESET: case PSN_KILLACTIVE: SetEvent( thread_stop ); - MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, 0 ); + /* wait for the input thread to stop, processing any WM_USER message from it */ + while (MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, QS_ALLINPUT )) + { + MSG msg; + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } + } CloseHandle( thread_stop ); CloseHandle( thread ); dialog_hwnd = 0;