# HG changeset patch # User Rik # Date 1470885459 25200 # Node ID 93d475551be2b1a538e327fca2d18f58f30c3372 # Parent 22f45a6b4693da0aeda320d790be561eda70bb5a material.m: Stop creation of blank figures until after input validation. * material.m: Don't call gca until after all input validation has occurred. diff -r 22f45a6b4693 -r 93d475551be2 scripts/plot/appearance/material.m --- 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 a = material ({}) %!error a = material ([.3 .4 .5]) %!error [a, b] = material () - -## Test error handling, all following errors require a figure -%!error -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material (-1, "metal") -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material foo -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect +%!error material (-1, "metal") +%!error material foo +%!error material (-1) +%!error material ([1 2 3 4 5 6]) +%!error material ({}) -%!error -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material (-1) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material ([1 2 3 4 5 6]) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error -%! hf = figure ("visible", "off"); -%! unwind_protect -%! material ({}) -%! unwind_protect_cleanup -%! close (hf); -%! end_unwind_protect - -%!error +%!error %! hf = figure ("visible", "off"); %! unwind_protect %! material (hf);