# HG changeset patch # User John W. Eaton # Date 1461962141 14400 # Node ID b45d53d1d638d95ca28f533c6009ac20fa63591c # Parent 6b5f90d9a10b34cf58d359395488da7323092748 prevent proliferation of figure windows when running demos * demo.m: If any figures are open, close all but one figure before each demo, clearing the last remaining figure. diff -r 6b5f90d9a10b -r b45d53d1d638 scripts/testfun/demo.m --- a/scripts/testfun/demo.m Fri Apr 29 15:33:56 2016 -0400 +++ b/scripts/testfun/demo.m Fri Apr 29 16:35:41 2016 -0400 @@ -126,10 +126,12 @@ else doidx = 1:(length (idx) - 1); endif + clear_figures (); for i = 1:length (doidx) ## Pause between demos if (i > 1) input ("Press to continue: ", "s"); + clear_figures (); endif ## Process each demo without failing @@ -149,6 +151,19 @@ endfunction +function clear_figures () + ## Prevent proliferation of figure windows. If any figure windows + ## exist, close all but one and clear the one remaining. + figs = __go_figure_handles__ (); + if (! isempty (figs)) + if (numel (figs) > 1) + figs = sort (figs); + figs(1) = []; + close (figs); + endif + clf ("reset"); + endif +endfunction %!demo %! t = 0:0.01:2*pi;