# HG changeset patch # User Philip Nienhuis # Date 1347068050 14400 # Node ID aaf938d17e0c8f9e150cd820f920d46204fe8bff # Parent 81cc4e5733b11e610037fdef4a6eb3fc3d81d5a2 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" diff --git a/scripts/miscellaneous/rmappdata.m b/scripts/miscellaneous/rmappdata.m --- 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); + diff --git a/scripts/plot/private/__go_draw_axes__.m b/scripts/plot/private/__go_draw_axes__.m --- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -47,7 +47,7 @@ else h = axis_obj.__plotyy_axes__; h = h(ishandle (h)); - h = h(isprop (h, "__ploty_axes__")); + h = h(isprop (h, "__plotyy_axes__")); rmappdata (h, "__plotyy_axes__"); endif endif