# HG changeset patch
# User Pantxo Diribarne <pantxo.diribarne@gmail.com>
# Date 1573633539 -3600
#      Wed Nov 13 09:25:39 2019 +0100
# Node ID 854033674ab7a4e14144d509855f83355f2e8b0b
# Parent  fad2b816df2da937e5e34a229f5ff85851d6200a
Hide and rename __appdata__ internal property (bug #57211)

* graphics.in.h (base_graphics_object::applicationdata): New hidden any_property
  that defaults to an empty struct.

* setappdata.m, getappadata.m, rmappdata.m, isappdata.m: Replace "__appdata__"
  to "applicationdata". Assume the property exists.

diff -r fad2b816df2d -r 854033674ab7 libinterp/corefcn/graphics.in.h
--- a/libinterp/corefcn/graphics.in.h	Tue Nov 12 22:37:19 2019 +0100
+++ b/libinterp/corefcn/graphics.in.h	Wed Nov 13 09:25:39 2019 +0100
@@ -2385,6 +2385,7 @@
     bool_property visible u , "on"
 
     // Octave-specific properties
+    any_property applicationdata h , octave_scalar_map ()
     bool_property __modified__ hs , "on"
     graphics_handle __myhandle__ fhrs , mh
   END_PROPERTIES
diff -r fad2b816df2d -r 854033674ab7 scripts/gui/getappdata.m
--- a/scripts/gui/getappdata.m	Tue Nov 12 22:37:19 2019 +0100
+++ b/scripts/gui/getappdata.m	Wed Nov 13 09:25:39 2019 +0100
@@ -50,7 +50,7 @@
     value = cell (numel (h), 1);
     for i = 1:numel (h)
       try
-        value{i} = (get (h(i), "__appdata__")).(name);
+        value{i} = (get (h(i), "applicationdata")).(name);
       end_try_catch
     endfor
 
@@ -62,11 +62,7 @@
     if (numel (h) != 1)
       error ("getappdata: Only one handle H may be used when fetching appdata");
     endif
-    try
-      value = get (h, "__appdata__");
-    catch
-      value = struct ();
-    end_try_catch
+    value = get (h, "applicationdata");
   endif
 
 endfunction
diff -r fad2b816df2d -r 854033674ab7 scripts/gui/isappdata.m
--- a/scripts/gui/isappdata.m	Tue Nov 12 22:37:19 2019 +0100
+++ b/scripts/gui/isappdata.m	Wed Nov 13 09:25:39 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), "applicationdata");
+    if (isfield (appdata, name))
+      valid(i) = true;
+    endif
   endfor
 
 endfunction
diff -r fad2b816df2d -r 854033674ab7 scripts/gui/rmappdata.m
--- a/scripts/gui/rmappdata.m	Tue Nov 12 22:37:19 2019 +0100
+++ b/scripts/gui/rmappdata.m	Wed Nov 13 09:25:39 2019 +0100
@@ -45,17 +45,15 @@
   endif
 
   for hg = h
-    if (isprop (hg, "__appdata__"))
-      appdata = get (hg, "__appdata__");
-      vld = isfield (appdata, varargin);
-      if (! all (vld))
-        ## FIXME: Should we bother to error out?  Or just silently continue?
-        missing = varargin{find (! vld, 1)};
-        error ("rmappdata: appdata '%s' is not present", missing);
-      endif
-      appdata = rmfield (appdata, varargin);
-      set (hg, "__appdata__", appdata);
+    appdata = get (hg, "applicationdata");
+    vld = isfield (appdata, varargin);
+    if (! all (vld))
+      ## FIXME: Should we bother to error out?  Or just silently continue?
+      missing = varargin{find (! vld, 1)};
+      error ("rmappdata: appdata '%s' is not present", missing);
     endif
+    appdata = rmfield (appdata, varargin);
+    set (hg, "applicationdata", appdata);
   endfor
 
 endfunction
diff -r fad2b816df2d -r 854033674ab7 scripts/gui/setappdata.m
--- a/scripts/gui/setappdata.m	Tue Nov 12 22:37:19 2019 +0100
+++ b/scripts/gui/setappdata.m	Wed Nov 13 09:25:39 2019 +0100
@@ -73,19 +73,14 @@
   endif
 
   for hg = h
-    try
-      appdata = get (hg, "__appdata__");
-    catch
-      appdata = struct ();
-      addproperty ("__appdata__", hg, "any", appdata);
-    end_try_catch
+    appdata = get (hg, "applicationdata");
 
     ## Slow, but not likely to be that many elements in loop
     for narg = 1:2:numel (varargin)
       appdata.(varargin{narg}) = varargin{narg+1};
     endfor
 
-    set (hg, "__appdata__", appdata);
+    set (hg, "applicationdata", appdata);
   endfor
 
 endfunction
diff -r fad2b816df2d -r 854033674ab7 scripts/plot/util/struct2hdl.m
--- a/scripts/plot/util/struct2hdl.m	Tue Nov 12 22:37:19 2019 +0100
+++ b/scripts/plot/util/struct2hdl.m	Wed Nov 13 09:25:39 2019 +0100
@@ -306,7 +306,7 @@
     ## remove all properties such as "textposition" that redefine
     ## the entire legend.  Also remove chidren.
     s.properties = rmfield (s.properties, ...
-                              {"__appdata__", "xlabel",...
+                              {"applicationdata", "xlabel",...
                                "ylabel", "zlabel", "location", ...
                                "title", "string","orientation", ...
                                "visible", "textposition"});
@@ -321,7 +321,7 @@
       location = s.properties.location;
       h = colorbar ("peer", ax, location);
       s.properties = rmfield (s.properties, ...
-                                {"__appdata__", "xlabel" ...
+                                {"applicationdata", "xlabel" ...
                                  "ylabel", "zlabel", ...
                                  "title", "axes"});
       s.children= [];
