Mercurial > hg > octave-lojdl
changeset 8264:bca580bbda02
cla.m: Fix error when no children to clear.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 22 Oct 2008 13:57:32 -0400 |
parents | 22c078fd926b |
children | 1c213dff76fc |
files | scripts/ChangeLog scripts/plot/cla.m |
diffstat | 2 files changed, 26 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-10-22 Ben Abbott <bpabbott@mac.com> + + * plot/cla.m: Fix error when no children to clear. + 2008-10-22 John W. Eaton <jwe@octave.org> * plot/allchild.m: Move call to get showhiddenhandles outside of
--- 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)