changeset 10661:3df114a44da3

ancestor.m: Support vectors of handles.
author Ben Abbott <bpabbott@mac.com>
date Wed, 26 May 2010 19:49:12 -0400
parents 4cdc43c095c5
children 3afcd24ced61
files scripts/ChangeLog scripts/plot/ancestor.m
diffstat 2 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed May 26 15:51:02 2010 -0700
+++ b/scripts/ChangeLog	Wed May 26 19:49:12 2010 -0400
@@ -1,3 +1,7 @@
+2010-05-26  Ben Abbott <bpabbott@mac.com>
+
+	* plot/ancestor.m: Support vectors of handles.
+
 2010-05-26  Rik <octave@nomad.inbox5.com>
         * sparse/svds.m: Initialize ARPACK starting vector in svds test code.
         Bug #29721.
--- a/scripts/plot/ancestor.m	Wed May 26 15:51:02 2010 -0700
+++ b/scripts/plot/ancestor.m	Wed May 26 19:49:12 2010 -0400
@@ -35,7 +35,7 @@
 function p = ancestor (h, type, toplevel)
 
   if (nargin == 2 || nargin == 3)
-    p = [];
+    p = cell (numel (h), 1);
     if (ischar (type))
       type = { type };
     endif
@@ -48,18 +48,24 @@
           error ("ancestor: third argument must be \"toplevel\"");
         endif
       endif
-      while (true)
-        if (isempty (h) || ! ishandle (h))
-          break;
-        endif
-        if (any (strcmpi (get (h, "type"), type)))
-          p = h;
-          if (look_first)
+      h = num2cell (h);
+      for nh = 1:numel(h)
+        while (true)
+          if (isempty (h{nh}) || ! ishandle (h{nh}))
             break;
           endif
-        endif
-                h = get (h, "Parent");
-      endwhile
+          if (any (strcmpi (get (h{nh}, "type"), type)))
+            p{nh} = h{nh};
+            if (look_first)
+              break;
+            endif
+          endif
+          h{nh} = get (h{nh}, "Parent");
+        endwhile
+      endfor
+      if (nh == 1)
+        p = p{1};
+      endif
     else
       error ("ancestor: second argument must be a string or cell array of strings");
     endif