Flush message queue when shutting down video mode on Windows
authorSam Lantinga <slouken@libsdl.org>
Sat, 17 Aug 2002 19:17:18 +0000
changeset 442b37ce4813ad4
parent 441 598b25b9bffe
child 443 778b970cec12
Flush message queue when shutting down video mode on Windows
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5video.c
     1.1 --- a/src/video/windib/SDL_dibvideo.c	Sat Aug 17 19:17:01 2002 +0000
     1.2 +++ b/src/video/windib/SDL_dibvideo.c	Sat Aug 17 19:17:18 2002 +0000
     1.3 @@ -889,6 +889,16 @@
     1.4  #endif /* !NO_GAMMA_SUPPORT */
     1.5  }
     1.6  
     1.7 +static void FlushMessageQueue()
     1.8 +{
     1.9 +	MSG  msg;
    1.10 +	while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) {
    1.11 +		if ( msg.message == WM_QUIT ) break;
    1.12 +		TranslateMessage( &msg );
    1.13 +		DispatchMessage( &msg );
    1.14 +	}
    1.15 +}
    1.16 +
    1.17  void DIB_VideoQuit(_THIS)
    1.18  {
    1.19  	/* Destroy the window and everything associated with it */
    1.20 @@ -918,6 +928,7 @@
    1.21  		}
    1.22  		DIB_QuitGamma(this);
    1.23  		DIB_DestroyWindow(this);
    1.24 +		FlushMessageQueue();
    1.25  
    1.26  		SDL_Window = NULL;
    1.27  	}
     2.1 --- a/src/video/windx5/SDL_dx5video.c	Sat Aug 17 19:17:01 2002 +0000
     2.2 +++ b/src/video/windx5/SDL_dx5video.c	Sat Aug 17 19:17:18 2002 +0000
     2.3 @@ -2205,6 +2205,16 @@
     2.4  #endif /* !IDirectDrawGammaControl_SetGammaRamp */
     2.5  }
     2.6  
     2.7 +static void FlushMessageQueue()
     2.8 +{
     2.9 +	MSG  msg;
    2.10 +	while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) {
    2.11 +		if ( msg.message == WM_QUIT ) break;
    2.12 +		TranslateMessage( &msg );
    2.13 +		DispatchMessage( &msg );
    2.14 +	}
    2.15 +}
    2.16 +
    2.17  void DX5_VideoQuit(_THIS)
    2.18  {
    2.19  	int i, j;
    2.20 @@ -2246,6 +2256,7 @@
    2.21  	DIB_QuitGamma(this);
    2.22  	if ( SDL_Window ) {
    2.23  		DX5_DestroyWindow(this);
    2.24 +		FlushMessageQueue();
    2.25  	}
    2.26  
    2.27  	/* Free our window icon */