# HG changeset patch # User John W. Eaton # Date 1425350073 18000 # Node ID 00c3f2021cad1ccbef7ba601216e1e5bb47032b6 # Parent e1d7bd38b82b0d28320759aa885ff1124975f924 use unwind_protect to restore static variable value (bug #44406) * gl2ps-renderer.cc (glps_renderer::draw): Use unwind_protect to save and restore value of static variable in_draw. diff -r e1d7bd38b82b -r 00c3f2021cad libinterp/corefcn/gl2ps-renderer.cc --- a/libinterp/corefcn/gl2ps-renderer.cc Mon Mar 02 21:00:13 2015 -0500 +++ b/libinterp/corefcn/gl2ps-renderer.cc Mon Mar 02 21:34:33 2015 -0500 @@ -46,6 +46,10 @@ if (!in_draw) { + unwind_protect frame; + + frame.protect_var (in_draw); + in_draw = true; GLint buffsize = 0; @@ -108,7 +112,6 @@ buffsize, fp, include_graph.c_str ()); if (ret == GL2PS_ERROR) { - in_draw = 0; old_print_cmd.clear (); error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); return; @@ -127,7 +130,6 @@ } else if (state == GL2PS_ERROR) { - in_draw = 0; old_print_cmd.clear (); error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR"); return; @@ -135,8 +137,6 @@ // Don't check state for GL2PS_UNINITIALIZED (should never happen) // GL2PS_OVERFLOW (see while loop) or GL2PS_SUCCESS } - - in_draw = 0; } else opengl_renderer::draw (go);