From: Carlos Garcia Campos Date: Sat, 3 Feb 2007 11:57:03 +0000 (+0000) Subject: Handle ghostscript interpreter crashes. X-Git-Tag: EVINCE_0_7_2~33 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=2a93cb5f8df446b1f9c891c8170011a581ba2905;p=evince.git Handle ghostscript interpreter crashes. 2007-02-03 Carlos Garcia Campos * backend/ps/ps-document.c: (ps_interpreter_finished), (ps_interpreter_start), (ps_interpreter_failed): Handle ghostscript interpreter crashes. svn path=/trunk/; revision=2288 --- diff --git a/ChangeLog b/ChangeLog index c1006046..bb90356b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-02-03 Carlos Garcia Campos + + * backend/ps/ps-document.c: (ps_interpreter_finished), + (ps_interpreter_start), (ps_interpreter_failed): + + Handle ghostscript interpreter crashes. + 2007-02-02 Carlos Garcia Campos * shell/ev-window.c: (ev_window_open_uri), diff --git a/backend/ps/ps-document.c b/backend/ps/ps-document.c index 79f29cbd..1e448e38 100644 --- a/backend/ps/ps-document.c +++ b/backend/ps/ps-document.c @@ -421,6 +421,16 @@ ps_interpreter_error (GIOChannel *io, return TRUE; } +static void +ps_interpreter_finished (GPid pid, + gint status, + PSDocument *gs) +{ + g_spawn_close_pid (gs->interpreter_pid); + gs->interpreter_pid = -1; + ps_interpreter_failed (gs, NULL); +} + #define NUM_ARGS 100 #define NUM_GS_ARGS (NUM_ARGS - 20) #define NUM_ALPHA_ARGS 10 @@ -485,13 +495,17 @@ ps_interpreter_start (PSDocument *gs) envp = g_strsplit (gv_env, ";", 2); g_free (gv_env); - if (g_spawn_async_with_pipes (dir, argv, NULL, 0, + if (g_spawn_async_with_pipes (dir, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, (GSpawnChildSetupFunc)setup_interpreter_env, envp, &(gs->interpreter_pid), &pin, &pout, &perr, &error)) { GIOFlags flags; + g_child_watch_add (gs->interpreter_pid, + (GChildWatchFunc)ps_interpreter_finished, + gs); + gs->interpreter_input = g_io_channel_unix_new (pin); g_io_channel_set_encoding (gs->interpreter_input, NULL, NULL); flags = g_io_channel_get_flags (gs->interpreter_input); @@ -585,8 +599,7 @@ ps_interpreter_stop (PSDocument *gs) static void ps_interpreter_failed (PSDocument *gs, const char *msg) { - if (msg) - g_warning (msg); + g_warning (msg ? msg : _("Interpreter failed.")); push_pixbuf (gs); ps_interpreter_stop (gs);