changeset 19636:3da4b083e0b8

getappdata.m: fix output for multiple handles (bug #44097) * getappdata.m: replace try/catch by tests on property/value structure, fix output and remove FIXME comment
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 27 Jan 2015 18:55:25 +0100
parents bdf90710dddf
children 61cc00ebac60
files scripts/miscellaneous/getappdata.m
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/getappdata.m	Sat Oct 04 02:17:17 2014 -0500
+++ b/scripts/miscellaneous/getappdata.m	Tue Jan 27 18:55:25 2015 +0100
@@ -47,18 +47,14 @@
       error ("getappdata: NAME must be a string");
     endif
 
-    ## FIXME: Is there a better way to handle non-existent appdata
-    ##        and missing fields?
     value = cell (numel (h), 1);
     appdata = struct ();
     for i = 1:numel (h)
-      try
-        appdata = get (h(i), "__appdata__");
-      end_try_catch
-      if (isfield (appdata, name))
-        value(i) = {appdata.(name)};
-      else
-        value(i) = {[]};
+      value{i} = [];
+      pval = get (h(i));
+      if (isfield (pval, "__appdata__") &&
+          isfield (pval.__appdata__, name))
+        value{i} = pval.__appdata__.(name);
       endif
     endfor