# HG changeset patch # User jwe # Date 1174919304 0 # Node ID 7c9b4a6e090b8e7eac412b9b105a9f1323e3af7f # Parent 4067a8caff18d328988971aacce0d1a824e66d86 [project @ 2007-03-26 14:28:24 by jwe] diff -r 4067a8caff18 -r 7c9b4a6e090b scripts/ChangeLog --- a/scripts/ChangeLog Mon Mar 26 14:15:24 2007 +0000 +++ b/scripts/ChangeLog Mon Mar 26 14:28:24 2007 +0000 @@ -1,5 +1,7 @@ 2007-03-26 John W. Eaton + * plot/drawnow.m: Exit early if call is recursive. + * plot/__go_draw_axes__.m (get_data_limits): New function. Check for Inf too. (__go_draw_axes__): Use get_data_limits. diff -r 4067a8caff18 -r 7c9b4a6e090b scripts/plot/drawnow.m --- a/scripts/plot/drawnow.m Mon Mar 26 14:15:24 2007 +0000 +++ b/scripts/plot/drawnow.m Mon Mar 26 14:28:24 2007 +0000 @@ -26,48 +26,61 @@ function drawnow (term, file) - if (nargin == 2) - h = get (0, "currentfigure"); - if (h) - f = get (h); - plot_stream = []; - unwind_protect - plot_stream = open_gnuplot_stream ([], term, file); - __go_draw_figure__ (f, plot_stream); - unwind_protect_cleanup - if (! isempty (plot_stream)) - pclose (plot_stream); - endif - end_unwind_protect - else - error ("drawnow: nothing to draw"); + persistent drawnow_executing = 0; + + unwind_protect + + ## If this is a recursive call, do nothing. + if (++drawnow_executing > 1) + return; endif - elseif (nargin == 0) - for h = __go_figure_handles__ () - if (! (isnan (h) || h == 0)) + + if (nargin == 2) + h = get (0, "currentfigure"); + if (h) f = get (h); - if (f.__modified__) - plot_stream = f.__plot_stream__; - figure_is_visible = strcmp (f.visible, "on"); - if (figure_is_visible) - if (isempty (plot_stream)) - plot_stream = open_gnuplot_stream (h); - endif - __go_draw_figure__ (f, plot_stream); - elseif (! isempty (plot_stream)) + plot_stream = []; + unwind_protect + plot_stream = open_gnuplot_stream ([], term, file); + __go_draw_figure__ (f, plot_stream); + unwind_protect_cleanup + if (! isempty (plot_stream)) pclose (plot_stream); - set (h, "__plot_stream__", []); endif - set (h, "__modified__", false); - endif - __request_drawnow__ (false); + end_unwind_protect + else + error ("drawnow: nothing to draw"); endif - endfor - else - print_usage (); - endif + elseif (nargin == 0) + for h = __go_figure_handles__ () + if (! (isnan (h) || h == 0)) + f = get (h); + if (f.__modified__) + plot_stream = f.__plot_stream__; + figure_is_visible = strcmp (f.visible, "on"); + if (figure_is_visible) + if (isempty (plot_stream)) + plot_stream = open_gnuplot_stream (h); + endif + __go_draw_figure__ (f, plot_stream); + elseif (! isempty (plot_stream)) + pclose (plot_stream); + set (h, "__plot_stream__", []); + endif + set (h, "__modified__", false); + endif + endif + endfor + else + print_usage (); + endif - __request_drawnow__ (false); + unwind_protect_cleanup + + drawnow_executing--; + __request_drawnow__ (false); + + end_unwind_protect endfunction