diff --git a/libinterp/corefcn/gl2ps-print.cc b/libinterp/corefcn/gl2ps-print.cc --- a/libinterp/corefcn/gl2ps-print.cc +++ b/libinterp/corefcn/gl2ps-print.cc @@ -48,6 +48,20 @@ along with Octave; see the file COPYING. #include "sysdep.h" #include "text-renderer.h" +static void +safe_pclose (FILE *f) +{ + if (f) + octave_pclose (f); +} + +static void +safe_fclose (FILE *f) +{ + if (f) + std::fclose (f); +} + namespace octave { class @@ -238,6 +252,8 @@ namespace octave if (! tmpf) error ("gl2ps_renderer::draw: couldn't open temporary file for printing"); + frame.add_fcn (safe_fclose, tmpf); + // Reset buffsize, unless this is 2nd pass of a texstandalone print. if (term.find ("tex") == std::string::npos) buffsize = 2*1024*1024; @@ -812,20 +828,6 @@ namespace octave } -static void -safe_pclose (FILE *f) -{ - if (f) - octave_pclose (f); -} - -static void -safe_fclose (FILE *f) -{ - if (f) - std::fclose (f); -} - #endif namespace octave