# HG changeset patch # User Ben Abbott # Date 1224698252 14400 # Node ID bca580bbda02ba8fd6741981690964f20998e116 # Parent 22c078fd926bf99a451391e1e7b660dc75d287b0 cla.m: Fix error when no children to clear. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-10-22 Ben Abbott + + * plot/cla.m: Fix error when no children to clear. + 2008-10-22 John W. Eaton * plot/allchild.m: Move call to get showhiddenhandles outside of diff --git a/scripts/plot/cla.m b/scripts/plot/cla.m --- a/scripts/plot/cla.m +++ b/scripts/plot/cla.m @@ -64,15 +64,17 @@ do_reset = false; end - if (do_reset) - hc = get (hax, "children"); - else - hc = findobj (get (hax, "children"), "flat", "visible", "on"); + hc = get (hax, "children"); + + if (! do_reset && ! isempty (hc)) + hc = findobj (hc, "flat", "visible", "on"); hc = setdiff (hc, hax); end - ## Delete the children of the axis. - delete (hc); + if (! isempty (hc)) + ## Delete the children of the axis. + delete (hc); + endif ## FIXME: The defaults should be "reset()" below, but so far there is ## no method to determine the defaults, much less return an object's @@ -86,3 +88,17 @@ axes (oldhax); endfunction + +%!test +%! hf = figure; +%! unwind_protect +%! set (hf, "visible", "off") +%! clf +%! plot (1:10) +%! cla () +%! kids = get (gca, "children"); +%! cla () +%! unwind_protect_cleanup +%! close (hf) +%! end_unwind_protect +%! assert (numel (kids), 0)