]> www.fi.muni.cz Git - evince.git/commitdiff
Handle ghostscript interpreter crashes.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 3 Feb 2007 11:57:03 +0000 (11:57 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sat, 3 Feb 2007 11:57:03 +0000 (11:57 +0000)
2007-02-03  Carlos Garcia Campos  <carlosgc@gnome.org>
* backend/ps/ps-document.c: (ps_interpreter_finished),
(ps_interpreter_start), (ps_interpreter_failed):
Handle ghostscript interpreter crashes.

svn path=/trunk/; revision=2288

ChangeLog
backend/ps/ps-document.c

index c1006046eb1407baa306da2b028d9c4294e3c1fe..bb90356bacca3dda17781a33a9d9b368bf83e0d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-02-03  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/ps/ps-document.c: (ps_interpreter_finished),
+       (ps_interpreter_start), (ps_interpreter_failed):
+
+       Handle ghostscript interpreter crashes. 
+
 2007-02-02  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-window.c: (ev_window_open_uri),
index 79f29cbdea05d21af09120d96e4a4458eadcf1d6..1e448e38f1c3dece75cd5ae6e80b59ca49d99de2 100644 (file)
@@ -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);