Eric Pouech : wineconsole: Ensure that the EXIT message is always properly propagated to the first caller of GrabChanges .

Alexandre Julliard julliard at winehq.org
Mon Mar 28 14:21:55 CDT 2011


Module: wine
Branch: master
Commit: 51f06239ffff85b11b1eaa3fb660d517f95ee0c4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=51f06239ffff85b11b1eaa3fb660d517f95ee0c4

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Sun Mar 20 09:18:10 2011 +0100

wineconsole: Ensure that the EXIT message is always properly propagated to the first caller of GrabChanges.

---

 programs/wineconsole/curses.c          |    5 ++---
 programs/wineconsole/user.c            |    7 ++++---
 programs/wineconsole/winecon_private.h |    5 +++--
 programs/wineconsole/wineconsole.c     |    8 ++++----
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c
index fc0261f..00e5039 100644
--- a/programs/wineconsole/curses.c
+++ b/programs/wineconsole/curses.c
@@ -1009,17 +1009,16 @@ static void WCCURSES_DeleteBackend(struct inner_data* data)
 static int WCCURSES_MainLoop(struct inner_data* data)
 {
     DWORD       id;
-    BOOL        cont = TRUE;
 
     WCCURSES_Resize(data);
 
     if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 0;
     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);
-        cont = WINECON_GrabChanges(data);
+        WINECON_GrabChanges(data);
         LeaveCriticalSection(&PRIVATE(data)->lock);
     }
 
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
index bc70a6b..22f33b1 100644
--- a/programs/wineconsole/user.c
+++ b/programs/wineconsole/user.c
@@ -1368,13 +1368,12 @@ static int WCUSER_MainLoop(struct inner_data* data)
     MSG		msg;
 
     ShowWindow(data->hWnd, data->nCmdShow);
-    for (;;)
+    while (!data->dying || !data->curcfg.exit_on_die)
     {
 	switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT))
 	{
 	case WAIT_OBJECT_0:
-	    if (!WINECON_GrabChanges(data) && data->curcfg.exit_on_die)
-                PostQuitMessage(0);
+	    WINECON_GrabChanges(data);
 	    break;
 	case WAIT_OBJECT_0+1:
             /* need to use PeekMessageW loop instead of simple GetMessage:
@@ -1393,6 +1392,8 @@ static int WCUSER_MainLoop(struct inner_data* data)
 	    break;
 	}
     }
+    PostQuitMessage(0);
+    return 0;
 }
 
 /******************************************************************
diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h
index 8f08ff4..ca5cb8c 100644
--- a/programs/wineconsole/winecon_private.h
+++ b/programs/wineconsole/winecon_private.h
@@ -61,6 +61,7 @@ struct inner_data {
     HWND		hWnd;           /* handle of 'user' window or NULL for 'curses' */
     INT                 nCmdShow;       /* argument of WinMain */
     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);
     void		(*fnPosCursor)(const struct inner_data* data);
@@ -82,8 +83,8 @@ extern void WINECON_ResizeWithContainer(struct inner_data* data, int width, int
 extern int  WINECON_GetHistorySize(HANDLE hConIn);
 extern int  WINECON_GetHistoryMode(HANDLE hConIn);
 extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len);
-extern int  WINECON_GrabChanges(struct inner_data* data);
-extern VOID WINECON_SetConfig(struct inner_data* data,
+extern void WINECON_GrabChanges(struct inner_data* data);
+extern void WINECON_SetConfig(struct inner_data* data,
                               const struct config_data* cfg);
 /* from registry.c */
 extern void WINECON_RegLoad(const WCHAR* appname, struct config_data* cfg);
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index ca20763..2938857 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -199,7 +199,7 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
  *
  * 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];
     int	i, num, ev_found;
@@ -213,7 +213,7 @@ int	WINECON_GrabChanges(struct inner_data* data)
         else num = 0;
     }
     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) */
     /* step 1: keep only last cursor pos event */
@@ -344,15 +344,15 @@ int	WINECON_GrabChanges(struct inner_data* data)
 	    }
 	    break;
 	case CONSOLE_RENDERER_EXIT_EVENT:
+            data->dying = TRUE;
 	    WINE_TRACE(". Exit!!\n");
-	    return 0;
+	    return;
 	default:
 	    WINE_FIXME("Unknown event type (%d)\n", evts[i].event);
 	}
     }
 
     WINE_TRACE(".\n");
-    return 1;
 }
 
 /******************************************************************




More information about the wine-cvs mailing list