diff -r e971caa4c2bb src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc Fri Nov 26 04:19:58 2010 -0500 +++ b/src/DLD-FUNCTIONS/fltk_backend.cc Thu Dec 02 21:25:58 2010 +0100 @@ -90,7 +90,7 @@ public: OpenGL_fltk (int xx, int yy, int ww, int hh, double num) : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), renderer (), - in_zoom (false), zoom_box (), print_fid (-1) + in_zoom (false), zoom_box (), print_fid (NULL) { // Ask for double buffering and a depth buffer. mode (FL_DEPTH | FL_DOUBLE); @@ -108,7 +108,7 @@ bool zoom (void) { return in_zoom; } void set_zoom_box (const Matrix& zb) { zoom_box = zb; } - void print (const int fid, const std::string& term) + void print (FILE *fid, const std::string& term) { print_fid = fid; print_term = term; @@ -128,7 +128,7 @@ // (x1,y1,x2,y2) Matrix zoom_box; - int print_fid; + FILE *print_fid; std::string print_term; void setup_viewport (int ww, int hh) @@ -150,7 +150,7 @@ { opengl_renderer *rend = new glps_renderer (print_fid, print_term); rend->draw (gh_manager::lookup (number)); - print_fid = -1; + print_fid = NULL; delete rend; } else @@ -744,7 +744,7 @@ // FIXME -- this could change. double number (void) { return fp.get___myhandle__ ().value (); } - void print (const int fid, const std::string& term) + void print (FILE *fid, const std::string& term) { canvas->print (fid, term); @@ -1473,7 +1473,7 @@ return get_size (hnd2idx (gh)); } - static void print (const graphics_handle& gh , const int fid, const std::string& term) + static void print (const graphics_handle& gh , FILE *fid, const std::string& term) { if (instance_ok ()) instance->do_print (hnd2idx(gh), fid, term); @@ -1612,7 +1612,7 @@ return sz; } - void do_print (int idx, const int fid, const std::string& term) + void do_print (int idx, FILE *fid, const std::string& term) { wm_iterator win; if ((win = windows.find (idx)) != windows.end ()) @@ -1835,14 +1835,12 @@ void print_figure (const graphics_object& go, const std::string& term, - const std::string& file, bool /*mono*/, + const std::string& file, FILE *fp, bool /*mono*/, const std::string& /*debug_file*/) const { - int fid; - std::istringstream istr (file); - if (istr >> fid) + if (fp) { - figure_manager::print (go.get_handle (), fid, term); + figure_manager::print (go.get_handle (), fp, term); redraw_figure (go); } else diff -r e971caa4c2bb src/gl2ps-renderer.cc --- a/src/gl2ps-renderer.cc Fri Nov 26 04:19:58 2010 -0500 +++ b/src/gl2ps-renderer.cc Thu Dec 02 21:25:58 2010 +0100 @@ -43,7 +43,6 @@ { in_draw = true; - FILE *fp = fdopen (fid, "wb"); GLint buffsize = 0, state = GL2PS_OVERFLOW; GLint viewport[4]; @@ -74,14 +73,12 @@ | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT | gl2ps_text), GL_RGBA, 0, NULL, 0, 0, 0, - buffsize, fp, "" ); + buffsize, fid, "" ); opengl_renderer::draw (go); state = gl2psEndPage (); } - gnulib::fclose (fp); - in_draw = 0; } else diff -r e971caa4c2bb src/gl2ps-renderer.h --- a/src/gl2ps-renderer.h Fri Nov 26 04:19:58 2010 -0500 +++ b/src/gl2ps-renderer.h Thu Dec 02 21:25:58 2010 +0100 @@ -31,7 +31,7 @@ glps_renderer : public opengl_renderer { public: - glps_renderer (const int _fid, const std::string& _term) + glps_renderer (FILE *_fid, const std::string& _term) : opengl_renderer () , fid (_fid), term (_term) { } ~glps_renderer (void) { } @@ -74,7 +74,7 @@ } private: - int fid; + FILE *fid; caseless_str term; double fontsize; std::string fontname; diff -r e971caa4c2bb src/graphics.cc --- a/src/graphics.cc Fri Nov 26 04:19:58 2010 -0500 +++ b/src/graphics.cc Thu Dec 02 21:25:58 2010 +0100 @@ -2343,7 +2343,7 @@ } void print_figure (const graphics_object& go, const std::string& term, - const std::string& file, bool mono, + const std::string& file, FILE *fp, bool mono, const std::string& debug_file) const { octave_value_list args; @@ -6817,8 +6817,15 @@ gh_manager::unlock (); + int fid; + std::istringstream istr (file); + istr >> fid; + FILE *fp = fdopen (fid, "wb"); // Can/should we get this from gnulib? + go.get_backend () - .print_figure (go, term, file, mono, debug_file); + .print_figure (go, term, file, fp, mono, debug_file); + + gnulib::fclose (fp); gh_manager::lock (); } diff -r e971caa4c2bb src/graphics.h.in --- a/src/graphics.h.in Fri Nov 26 04:19:58 2010 -0500 +++ b/src/graphics.h.in Thu Dec 02 21:25:58 2010 +0100 @@ -1777,7 +1777,7 @@ { gripe_invalid ("redraw_figure"); } virtual void print_figure (const graphics_object&, const std::string&, - const std::string&, bool, + const std::string&, FILE *fp, bool, const std::string& = "") const { gripe_invalid ("print_figure"); } @@ -1884,9 +1884,9 @@ { rep->redraw_figure (go); } void print_figure (const graphics_object& go, const std::string& term, - const std::string& file, bool mono, + const std::string& file, FILE *fp, bool mono, const std::string& debug_file = "") const - { rep->print_figure (go, term, file, mono, debug_file); } + { rep->print_figure (go, term, file, fp, mono, debug_file); } Matrix get_canvas_size (const graphics_handle& fh) const { return rep->get_canvas_size (fh); }