Mercurial > octave
changeset 30969:29573bab8328
maint: merge stable to default
author | Rik <rik@octave.org> |
---|---|
date | Fri, 29 Apr 2022 22:27:28 -0700 |
parents | ba701853b1bf (current diff) 9a9374ed5270 (diff) |
children | 58ca24f0d038 |
files | scripts/plot/util/findobj.m |
diffstat | 1 files changed, 21 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/findobj.m Wed Apr 27 19:03:12 2022 +0200 +++ b/scripts/plot/util/findobj.m Fri Apr 29 22:27:28 2022 -0700 @@ -101,28 +101,30 @@ handles = 0; n1 = 0; else - if (! isempty (varargin{1})) - if (ishghandle (varargin{1}(1))) - handles = varargin{1}; - n1 = 2; - else - handles = 0; - n1 = 1; - endif - else + if (isempty (varargin{1})) ## Return [](0x1) for compatibility. h = zeros (0, 1); return; endif + arg1 = varargin{1}; + if (isnumeric (arg1)) + if (! all (ishghandle (arg1))) + error ("findobj: invalid graphics handles in input HLIST"); + endif + handles = arg1; + n1 = 2; + else + handles = 0; + n1 = 1; + endif if (n1 <= nargin) - if (ischar (varargin{n1})) - if (strcmpi (varargin{n1}, "flat")) - depth = 0; - n1 += 1; - endif - else + if (! ischar (varargin{n1})) error ("findobj: properties and options must be strings"); endif + if (strcmpi (varargin{n1}, "flat")) + depth = 0; + n1 += 1; + endif endif endif @@ -443,3 +445,7 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect + +## Test input validation +%!error <invalid graphics handles in input HLIST> findobj ([0 1 10], "flat") +%!error <properties and options must be strings> findobj ({0}, "flat")