# HG changeset patch # User John W. Eaton # Date 1425221553 18000 # Sun Mar 01 09:52:33 2015 -0500 # Node ID 1cf114e1236646804adc24be7fa9d72fbcc38563 # Parent f25fe53690225633417c783208dbfd1673d93379 avoid crash with obsolete figure handles (bug #44330) * graphics.cc (F__process_graphics_events__): New function. * close.m: Use it. diff --git a/libinterp/corefcn/graphics.cc b/libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -11137,6 +11137,30 @@ undocumented.\n\ return retval; } +DEFUN (__process_graphics_events__, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} __process_graphics_events__ ()\n\ +Undocumented internal function.\n\ +@end deftypefn") +{ + static int process_events_executing = 0; + + octave_value retval; + + unwind_protect frame; + frame.protect_var (process_events_executing); + + if (++process_events_executing <= 1) + { + if (args.length () == 0) + gh_manager::process_events (); + else + print_usage (); + } + + return retval; +} + DEFUN (addlistener, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} addlistener (@var{h}, @var{prop}, @var{fcn})\n\ diff --git a/scripts/plot/util/close.m b/scripts/plot/util/close.m --- a/scripts/plot/util/close.m +++ b/scripts/plot/util/close.m @@ -82,6 +82,14 @@ function retval = close (arg1, arg2) __go_execute_callback__ (h, "closerequestfcn"); endfor + ## Force close function to execute now so that things like + ## + ## h = figure (); close (h); h = figure (); + ## + ## will work properly. + + __process_graphics_events__ (); + if (nargout > 0) retval = 1; endif