Mercurial > octave
changeset 22260:93d475551be2
material.m: Stop creation of blank figures until after input validation.
* material.m: Don't call gca until after all input validation has occurred.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 10 Aug 2016 20:17:39 -0700 |
parents | 22f45a6b4693 |
children | 77c4d43e06d1 |
files | scripts/plot/appearance/material.m |
diffstat | 1 files changed, 10 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/material.m Wed Aug 10 18:28:39 2016 -0700 +++ b/scripts/plot/appearance/material.m Wed Aug 10 20:17:39 2016 -0700 @@ -79,13 +79,12 @@ endif ## resolve input + h = []; if (nargout == 0) ## Check whether first argument is list of graphics handles. if (all (ishandle (varargin{1}))) h = varargin{1}; varargin(1) = []; - else - h = gca (); endif ## There must be one (additional) argument. @@ -173,6 +172,9 @@ error ("material: MTYPE must be a named material or a vector"); endif + if (isempty (h)) + h = gca (); + endif ## find all patch and surface objects in current axes hps = findobj (h, "Type", "patch", "-or", "Type", "surface"); @@ -296,49 +298,13 @@ %!error <Invalid call to material> a = material ({}) %!error <Invalid call to material> a = material ([.3 .4 .5]) %!error <Invalid call to material> [a, b] = material () - -## Test error handling, all following errors require a figure -%!error <first argument must be a list of handles> -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material (-1, "metal") -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error <unknown material type 'foo'> -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material foo -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect +%!error <first argument must be a list of handles> material (-1, "metal") +%!error <unknown material type 'foo'> material foo +%!error <incorrect number of elements in material vector> material (-1) +%!error <incorrect number of elements in material vector> material ([1 2 3 4 5 6]) +%!error <MTYPE must be a named material or a vector> material ({}) -%!error <incorrect number of elements in material vector> -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material (-1) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error <incorrect number of elements in material vector> -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material ([1 2 3 4 5 6]) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error <MTYPE must be a named material or a vector> -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material ({}) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error <Invalid call to material.> +%!error <Invalid call to material.> %! hf = figure ("visible", "off"); %! unwind_protect %! material (hf);