changeset 21656:6b5f90d9a10b

allow close to accept a column vector or matrix of handles * graphics.cc (F__go_execute_callback__): Handle array of handles. * close.m: Pass array of figure handles to __go_execute_callback__ instead of using a loop.
author John W. Eaton <jwe@octave.org>
date Fri, 29 Apr 2016 15:33:56 -0400
parents c32590cd0080
children b45d53d1d638
files libinterp/corefcn/graphics.cc scripts/plot/util/close.m
diffstat 2 files changed, 16 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Fri Apr 29 18:43:08 2016 +1000
+++ b/libinterp/corefcn/graphics.cc	Fri Apr 29 15:33:56 2016 -0400
@@ -10527,19 +10527,24 @@
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
-  double val = args(0).xdouble_value ("__go_execute_callback__: invalid graphics object");
-
-  graphics_handle h = gh_manager::lookup (val);
-
-  if (! h.ok ())
-    error ("__go_execute_callback__: invalid graphics object (= %g)", val);
+  const NDArray vals = args(0).xarray_value ("__go_execute_callback__: invalid graphics object");
 
   std::string name = args(1).xstring_value ("__go_execute_callback__: invalid callback name");
 
-  if (nargin == 2)
-    gh_manager::execute_callback (h, name);
-  else
-    gh_manager::execute_callback (h, name, args(2));
+  for (octave_idx_type i = 0; i < vals.numel (); i++)
+    {
+      double val = vals(i);
+
+      graphics_handle h = gh_manager::lookup (val);
+
+      if (! h.ok ())
+        error ("__go_execute_callback__: invalid graphics object (= %g)", val);
+
+      if (nargin == 2)
+        gh_manager::execute_callback (h, name);
+      else
+        gh_manager::execute_callback (h, name, args(2));
+    }
 
   return ovl ();
 }
--- a/scripts/plot/util/close.m	Fri Apr 29 18:43:08 2016 +1000
+++ b/scripts/plot/util/close.m	Fri Apr 29 15:33:56 2016 -0400
@@ -92,9 +92,7 @@
     error ('close: second argument must be "hidden" or "force"');
   endif
 
-  for h = figs
-    __go_execute_callback__ (h, "closerequestfcn");
-  endfor
+  __go_execute_callback__ (figs, "closerequestfcn");
 
   if (nargout > 0)
     retval = 1;