Commit 51f06239 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

wineconsole: Ensure that the EXIT message is always properly propagated to the…

wineconsole: Ensure that the EXIT message is always properly propagated to the first caller of GrabChanges.
parent 4220cd66
...@@ -1009,17 +1009,16 @@ static void WCCURSES_DeleteBackend(struct inner_data* data) ...@@ -1009,17 +1009,16 @@ static void WCCURSES_DeleteBackend(struct inner_data* data)
static int WCCURSES_MainLoop(struct inner_data* data) static int WCCURSES_MainLoop(struct inner_data* data)
{ {
DWORD id; DWORD id;
BOOL cont = TRUE;
WCCURSES_Resize(data); WCCURSES_Resize(data);
if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 0; if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 0;
PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id ); PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id );
while (cont && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0) while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0)
{ {
EnterCriticalSection(&PRIVATE(data)->lock); EnterCriticalSection(&PRIVATE(data)->lock);
cont = WINECON_GrabChanges(data); WINECON_GrabChanges(data);
LeaveCriticalSection(&PRIVATE(data)->lock); LeaveCriticalSection(&PRIVATE(data)->lock);
} }
......
...@@ -1368,13 +1368,12 @@ static int WCUSER_MainLoop(struct inner_data* data) ...@@ -1368,13 +1368,12 @@ static int WCUSER_MainLoop(struct inner_data* data)
MSG msg; MSG msg;
ShowWindow(data->hWnd, data->nCmdShow); ShowWindow(data->hWnd, data->nCmdShow);
for (;;) while (!data->dying || !data->curcfg.exit_on_die)
{ {
switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT)) switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT))
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
if (!WINECON_GrabChanges(data) && data->curcfg.exit_on_die) WINECON_GrabChanges(data);
PostQuitMessage(0);
break; break;
case WAIT_OBJECT_0+1: case WAIT_OBJECT_0+1:
/* need to use PeekMessageW loop instead of simple GetMessage: /* need to use PeekMessageW loop instead of simple GetMessage:
...@@ -1393,6 +1392,8 @@ static int WCUSER_MainLoop(struct inner_data* data) ...@@ -1393,6 +1392,8 @@ static int WCUSER_MainLoop(struct inner_data* data)
break; break;
} }
} }
PostQuitMessage(0);
return 0;
} }
/****************************************************************** /******************************************************************
......
...@@ -61,6 +61,7 @@ struct inner_data { ...@@ -61,6 +61,7 @@ struct inner_data {
HWND hWnd; /* handle of 'user' window or NULL for 'curses' */ HWND hWnd; /* handle of 'user' window or NULL for 'curses' */
INT nCmdShow; /* argument of WinMain */ INT nCmdShow; /* argument of WinMain */
BOOL in_set_config; /* to handle re-entrant calls to WINECON_SetConfig */ BOOL in_set_config; /* to handle re-entrant calls to WINECON_SetConfig */
BOOL dying; /* to TRUE when we've been notified by server that child has died */
int (*fnMainLoop)(struct inner_data* data); int (*fnMainLoop)(struct inner_data* data);
void (*fnPosCursor)(const struct inner_data* data); void (*fnPosCursor)(const struct inner_data* data);
...@@ -82,8 +83,8 @@ extern void WINECON_ResizeWithContainer(struct inner_data* data, int width, int ...@@ -82,8 +83,8 @@ extern void WINECON_ResizeWithContainer(struct inner_data* data, int width, int
extern int WINECON_GetHistorySize(HANDLE hConIn); extern int WINECON_GetHistorySize(HANDLE hConIn);
extern int WINECON_GetHistoryMode(HANDLE hConIn); extern int WINECON_GetHistoryMode(HANDLE hConIn);
extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len); extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len);
extern int WINECON_GrabChanges(struct inner_data* data); extern void WINECON_GrabChanges(struct inner_data* data);
extern VOID WINECON_SetConfig(struct inner_data* data, extern void WINECON_SetConfig(struct inner_data* data,
const struct config_data* cfg); const struct config_data* cfg);
/* from registry.c */ /* from registry.c */
extern void WINECON_RegLoad(const WCHAR* appname, struct config_data* cfg); extern void WINECON_RegLoad(const WCHAR* appname, struct config_data* cfg);
......
...@@ -199,7 +199,7 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode) ...@@ -199,7 +199,7 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
* *
* A change occurs, try to figure out which * A change occurs, try to figure out which
*/ */
int WINECON_GrabChanges(struct inner_data* data) void WINECON_GrabChanges(struct inner_data* data)
{ {
struct console_renderer_event evts[256]; struct console_renderer_event evts[256];
int i, num, ev_found; int i, num, ev_found;
...@@ -213,7 +213,7 @@ int WINECON_GrabChanges(struct inner_data* data) ...@@ -213,7 +213,7 @@ int WINECON_GrabChanges(struct inner_data* data)
else num = 0; else num = 0;
} }
SERVER_END_REQ; SERVER_END_REQ;
if (!num) {WINE_WARN("hmm renderer signaled but no events available\n"); return 1;} if (!num) {WINE_WARN("hmm renderer signaled but no events available\n"); return;}
/* FIXME: should do some event compression here (cursor pos, update) */ /* FIXME: should do some event compression here (cursor pos, update) */
/* step 1: keep only last cursor pos event */ /* step 1: keep only last cursor pos event */
...@@ -344,15 +344,15 @@ int WINECON_GrabChanges(struct inner_data* data) ...@@ -344,15 +344,15 @@ int WINECON_GrabChanges(struct inner_data* data)
} }
break; break;
case CONSOLE_RENDERER_EXIT_EVENT: case CONSOLE_RENDERER_EXIT_EVENT:
data->dying = TRUE;
WINE_TRACE(". Exit!!\n"); WINE_TRACE(". Exit!!\n");
return 0; return;
default: default:
WINE_FIXME("Unknown event type (%d)\n", evts[i].event); WINE_FIXME("Unknown event type (%d)\n", evts[i].event);
} }
} }
WINE_TRACE(".\n"); WINE_TRACE(".\n");
return 1;
} }
/****************************************************************** /******************************************************************
......
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