]> granicus.if.org Git - graphviz/commitdiff
fix problem reported with multiple file outputs from script languages
authorellson <devnull@localhost>
Mon, 29 Oct 2007 20:39:48 +0000 (20:39 +0000)
committerellson <devnull@localhost>
Mon, 29 Oct 2007 20:39:48 +0000 (20:39 +0000)
lib/common/emit.c
lib/gvc/gvc.c

index 1d93a020daaa1120d5ac82489ed4932fb86b7a68..35d9cc919ecf5eeb1d27b3625b28ceef4519003a 100644 (file)
@@ -1944,7 +1944,7 @@ static void init_job_dpi(GVJ_t *job, graph_t *g)
     if (GD_drawing(g)->dpi != 0) {
         job->dpi.x = job->dpi.y = (double)(GD_drawing(g)->dpi);
     }
-    else if (firstjob->device_sets_dpi) {
+    else if (firstjob && firstjob->device_sets_dpi) {
         job->dpi = firstjob->device_dpi;   /* some devices set dpi in initialize() */
     }
     else {
@@ -2725,15 +2725,19 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g)
 
        /* if we already have an active job list and the device doesn't support mutiple output files, or we are about to write to a different output device */
         firstjob = gvc->active_jobs;
-        if (firstjob
-           && (!(firstjob->flags & GVDEVICE_DOES_PAGES)
-             || (strcmp(job->output_langname,firstjob->output_langname)))) {
+        if (firstjob) {
+           if (! (firstjob->flags & GVDEVICE_DOES_PAGES)
+             || (strcmp(job->output_langname,firstjob->output_langname))) {
 
-           gvrender_end_job(firstjob);
-            gvdevice_finalize(firstjob); /* finalize previous jobs */
+               gvrender_end_job(firstjob);
+               gvdevice_finalize(firstjob); /* finalize previous jobs */
            
-            gvc->active_jobs = NULL; /* clear active list */
-           gvc->common.viewNum = 0;
+               gvc->active_jobs = NULL; /* clear active list */
+               gvc->common.viewNum = 0;
+               prevjob = NULL;
+            }
+        }
+        else {
            prevjob = NULL;
         }
 
index 4bfd4294af8222847a4b89c7b1dcc387214a1e7e..84b12303a97f1a91677370ca4517c796cc1f53d6 100644 (file)
@@ -88,7 +88,6 @@ int gvRender(GVC_t *gvc, graph_t *g, char *format, FILE *out)
 {
     int rc;
     GVJ_t *job;
-    GVJ_t *firstjob;
 
     g = g->root;
 
@@ -110,11 +109,9 @@ int gvRender(GVC_t *gvc, graph_t *g, char *format, FILE *out)
     if (out == NULL)
        job->flags |= OUTPUT_NOT_REQUIRED;
     gvRenderJobs(gvc, g);
-    firstjob = gvc->active_jobs;
-    if (firstjob) {
-       gvrender_end_job(firstjob);
-       gvdevice_finalize(firstjob);
-    }
+    gvrender_end_job(job);
+    gvdevice_finalize(job);
+    fflush(job->output_file);
     gvjobs_delete(gvc);
 
     return 0;
@@ -125,7 +122,6 @@ int gvRenderFilename(GVC_t *gvc, graph_t *g, char *format, char *filename)
 {
     int rc;
     GVJ_t *job;
-    GVJ_t *firstjob;
 
     g = g->root;
 
@@ -145,11 +141,9 @@ int gvRenderFilename(GVC_t *gvc, graph_t *g, char *format, char *filename)
     }
     gvjobs_output_filename(gvc, filename);
     gvRenderJobs(gvc, g);
-    firstjob = gvc->active_jobs;
-    if (firstjob) {
-       gvrender_end_job(firstjob);
-       gvdevice_finalize(firstjob);
-    }
+    gvrender_end_job(job);
+    gvdevice_finalize(job);
+    fflush(job->output_file);
     gvjobs_delete(gvc);
 
     return 0;