changeset 22753:50fa2d656326

Size gl2ps print buffer just once when printing tex formats (bug #49492). * gl2ps-print.cc: Save buffer size in a static variable between the two gl2ps print runs needed for tex formats.
author Rik <rik@octave.org>
date Sun, 13 Nov 2016 06:07:14 -0800
parents dc828d9a7f3a
children c38eb3b08284
files libinterp/corefcn/gl2ps-print.cc
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc	Thu Nov 10 20:03:02 2016 -0800
+++ b/libinterp/corefcn/gl2ps-print.cc	Sun Nov 13 06:07:14 2016 -0800
@@ -164,6 +164,7 @@
   {
     static bool in_draw = false;
     static std::string old_print_cmd;
+    static GLint buffsize;
 
     if (! in_draw)
       {
@@ -207,13 +208,19 @@
         if (! tmpf)
           error ("gl2ps_renderer::draw: couldn't open temporary file for printing");
 
-        GLint buffsize = 2*1024*1024;
+        // Reset buffsize, unless this is 2nd pass of a texstandalone print.
+        if (term.find ("tex") == std::string::npos)
+          buffsize = 2*1024*1024;
+        else
+          buffsize /= 2;
+
         buffer_overflow = true;
 
         while (buffer_overflow)
           {
             buffer_overflow = false;
             buffsize *= 2;
+
             std::fseek (tmpf, 0, SEEK_SET);
             octave_ftruncate_wrapper (fileno (tmpf), 0);