Do not block in Get_input() when Quit_is_required is set

This commit is contained in:
Thomas Bernard 2019-02-04 19:11:30 +01:00
parent 48b9213da3
commit f8bfad2f34
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -1212,13 +1212,17 @@ int Get_input(int sleep_time)
// This is done in this function because it's called after reading // This is done in this function because it's called after reading
// some user input. // some user input.
Flush_update(); Flush_update();
if (Quit_is_required)
return 1;
Key_ANSI = 0; Key_ANSI = 0;
Key_UNICODE = 0; Key_UNICODE = 0;
Key = 0; Key = 0;
#if defined(USE_SDL2) #if defined(USE_SDL2)
memset(Key_Text, 0, sizeof(Key_Text)); memset(Key_Text, 0, sizeof(Key_Text));
#endif #endif
Mouse_moved=0; Mouse_moved = 0;
Input_new_mouse_X = Mouse_X; Input_new_mouse_X = Mouse_X;
Input_new_mouse_Y = Mouse_Y; Input_new_mouse_Y = Mouse_Y;
Input_new_mouse_K = Mouse_K; Input_new_mouse_K = Mouse_K;
@ -1601,10 +1605,14 @@ int Get_input(int sleep_time)
// some user input. // some user input.
Flush_update(); Flush_update();
while (!user_feedback_required && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (Quit_is_required)
TranslateMessage(&msg); return 1;
DispatchMessage(&msg);
} while (!user_feedback_required && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// If the cursor was moved since last update, // If the cursor was moved since last update,
// it was erased, so we need to redraw it (with the preview brush) // it was erased, so we need to redraw it (with the preview brush)
@ -1617,10 +1625,11 @@ int Get_input(int sleep_time)
if (user_feedback_required) if (user_feedback_required)
{ {
// Process the WM_CHAR event that follow WM_KEYDOWN // Process the WM_CHAR event that follow WM_KEYDOWN
if(PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, PM_REMOVE)) { if(PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, PM_REMOVE))
{
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
return 1; return 1;
} }
if (sleep_time == 0) if (sleep_time == 0)