changeset 7966:5747be3ac497

Implement closereq as real callback execution
author John W. Eaton <jwe@octave.org>
date Tue, 22 Jul 2008 17:23:28 -0400
parents 6a6a030a3517
children 6add0f974aee
files scripts/ChangeLog scripts/plot/close.m scripts/plot/closereq.m
diffstat 3 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Jul 22 16:03:44 2008 -0400
+++ b/scripts/ChangeLog	Tue Jul 22 17:23:28 2008 -0400
@@ -1,3 +1,9 @@
+2008-07-21  Michael Goffioul  <michael.goffioul@gmail.com>
+
+	* plot/closereq.m: Use first gcbf to get the handle of the figure to
+	be closed.
+	* plot/close.m: Call __go_execute_callback__.
+
 2008-07-17  John W. Eaton  <jwe@octave.org>
 
 	* general/fliplr.m: Fix usage test.
--- a/scripts/plot/close.m	Tue Jul 22 16:03:44 2008 -0400
+++ b/scripts/plot/close.m	Tue Jul 22 17:23:28 2008 -0400
@@ -59,8 +59,7 @@
   endif
 
   for h = figs
-    set (0, "currentfigure", h);
-    feval (get (h, "closerequestfcn"));
+    __go_execute_callback__ (h, "closerequestfcn");
   endfor
 
   if (nargout > 0)
--- a/scripts/plot/closereq.m	Tue Jul 22 16:03:44 2008 -0400
+++ b/scripts/plot/closereq.m	Tue Jul 22 17:23:28 2008 -0400
@@ -28,8 +28,12 @@
 function closereq ()
 
   if (nargin == 0)
-    cf = get (0, "currentfigure");
-    if (cf != 0)
+    cf = gcbf ();
+    if (isempty (cf))
+      warning ("closereq: calling closereq from octave prompt is not supported, use `close' instead");
+      cf = get (0, "currentfigure");
+    endif
+    if (! isempty (cf) && cf != 0)
       delete (cf);
     endif
   else