Mercurial > octave
changeset 27682:e18237114cf8
Hide __appdata__ internal property (bug #57211).
* graphics.in.h (base_graphics_object::__appdata__): New hidden any_property
that defaults to an empty matrix.
* setappdata.m, isappdata.m, getappdata.m: Simplify code by removing try/catch
blocks now that "__appdata__" property is guaranteed to exist.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 12 Nov 2019 15:39:05 +0100 |
parents | 20b075f88f0a |
children | 6604b41ca63f |
files | libinterp/corefcn/graphics.in.h scripts/gui/getappdata.m scripts/gui/isappdata.m scripts/gui/setappdata.m |
diffstat | 4 files changed, 10 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.in.h Wed Nov 13 09:13:41 2019 -0500 +++ b/libinterp/corefcn/graphics.in.h Tue Nov 12 15:39:05 2019 +0100 @@ -2385,6 +2385,7 @@ bool_property visible u , "on" // Octave-specific properties + any_property __appdata__ h , Matrix () bool_property __modified__ hs , "on" graphics_handle __myhandle__ fhrs , mh END_PROPERTIES
--- a/scripts/gui/getappdata.m Wed Nov 13 09:13:41 2019 -0500 +++ b/scripts/gui/getappdata.m Tue Nov 12 15:39:05 2019 +0100 @@ -62,11 +62,11 @@ if (numel (h) != 1) error ("getappdata: Only one handle H may be used when fetching appdata"); endif - try - value = get (h, "__appdata__"); - catch + + value = get (h, "__appdata__"); + if (isempty (value)) value = struct (); - end_try_catch + endif endif endfunction
--- a/scripts/gui/isappdata.m Wed Nov 13 09:13:41 2019 -0500 +++ b/scripts/gui/isappdata.m Tue Nov 12 15:39:05 2019 +0100 @@ -42,12 +42,10 @@ valid = false (size (h)); for i = 1:numel (h) - try - appdata = get (h(i), "__appdata__"); - if (isfield (appdata, name)) - valid(i) = true; - endif - end_try_catch + appdata = get (h(i), "__appdata__"); + if (isfield (appdata, name)) + valid(i) = true; + endif endfor endfunction
--- a/scripts/gui/setappdata.m Wed Nov 13 09:13:41 2019 -0500 +++ b/scripts/gui/setappdata.m Tue Nov 12 15:39:05 2019 +0100 @@ -73,12 +73,7 @@ endif for hg = h - try - appdata = get (hg, "__appdata__"); - catch - appdata = struct (); - addproperty ("__appdata__", hg, "any", appdata); - end_try_catch + appdata = get (hg, "__appdata__"); ## Slow, but not likely to be that many elements in loop for narg = 1:2:numel (varargin)