From 50ceeea0caa96471ea32653643e57e5b36a53478 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Aug 2002 19:17:18 +0000 Subject: [PATCH] Flush message queue when shutting down video mode on Windows --- src/video/windib/SDL_dibvideo.c | 11 +++++++++++ src/video/windx5/SDL_dx5video.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 8c3d439f6..907a00fd9 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -889,6 +889,16 @@ int DIB_GetGammaRamp(_THIS, Uint16 *ramp) #endif /* !NO_GAMMA_SUPPORT */ } +static void FlushMessageQueue() +{ + MSG msg; + while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { + if ( msg.message == WM_QUIT ) break; + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } +} + void DIB_VideoQuit(_THIS) { /* Destroy the window and everything associated with it */ @@ -918,6 +928,7 @@ void DIB_VideoQuit(_THIS) } DIB_QuitGamma(this); DIB_DestroyWindow(this); + FlushMessageQueue(); SDL_Window = NULL; } diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index 1817b3b3e..8220edb48 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -2205,6 +2205,16 @@ static int DX5_GetGammaRamp(_THIS, Uint16 *ramp) #endif /* !IDirectDrawGammaControl_SetGammaRamp */ } +static void FlushMessageQueue() +{ + MSG msg; + while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { + if ( msg.message == WM_QUIT ) break; + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } +} + void DX5_VideoQuit(_THIS) { int i, j; @@ -2246,6 +2256,7 @@ void DX5_VideoQuit(_THIS) DIB_QuitGamma(this); if ( SDL_Window ) { DX5_DestroyWindow(this); + FlushMessageQueue(); } /* Free our window icon */