Mercurial > hg > octave-thorsten
changeset 15333:aaf938d17e0c draft
Verify appdata exists before removing a propery. Also verify the property
exists before removing it. Bug # 39720
* scripts/miscellaneous/rmappdata.m: Validate appdata exists before removing
a field. Validate the field exists before removing it.
* scripts/plot/private/__go_draw_axes__.m: Correcgt spelling; "ploty" > "plotyy"
author | Philip Nienhuis <philipnienhuis> |
---|---|
date | Fri, 07 Sep 2012 21:34:10 -0400 |
parents | 81cc4e5733b1 |
children | b613757ff5be |
files | scripts/miscellaneous/rmappdata.m scripts/plot/private/__go_draw_axes__.m |
diffstat | 2 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/rmappdata.m +++ b/scripts/miscellaneous/rmappdata.m @@ -30,16 +30,30 @@ endif for nh = 1:numel (h) - appdata = get (h(nh), "__appdata__"); - appdata = rmfield (appdata, varargin); - set (h(nh), "__appdata__", appdata); + if (isprop (h(nh), "__appdata__")) + appdata = get (h(nh), "__appdata__"); + for v = 1:numel(varargin) + if (isfield (appdata, varargin{v})) + appdata = rmfield (appdata, varargin{v}); + else + error ("rmappdata: appdata '%s' is not present") + endif + endfor + set (h(nh), "__appdata__", appdata); + endif endfor endfunction - %!test %! setappdata (0, "hello", "world"); %! rmappdata (0, "hello"); %! assert (isappdata (0, "hello"), false); +%!test +%! setappdata (0, "data1", rand (3)); +%! setappdata (0, "data2", {"hello", "world"}); +%! rmappdata (0, "data1", "data2"); +%! assert (isappdata (0, "data1"), false); +%! assert (isappdata (0, "data2"), false); +