changeset 6298:4553ff6b7ec7

[project @ 2007-02-10 16:33:33 by jwe]
author jwe
date Sat, 10 Feb 2007 16:33:33 +0000
parents a943cb9c8068
children 0bccc5944e00
files scripts/ChangeLog scripts/plot/__uiobject_delete__.m scripts/plot/__uiobject_globals__.m scripts/plot/drawnow.m
diffstat 4 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sat Feb 10 08:42:27 2007 +0000
+++ b/scripts/ChangeLog	Sat Feb 10 16:33:33 2007 +0000
@@ -1,3 +1,12 @@
+2007-02-10  John W. Eaton  <jwe@octave.org>
+
+	* plot/drawnow.m: Arrange for plot streams to be close on exit.
+	* plot/__uiobject_globals__.m: Don't call mlock.
+
+	* plot/drawnow.m: Only check for DISPLAY if isunix returns true.
+	* plot/__uiobject_delete__.m: Send quit command and flush stream
+	before calling pclose.
+
 2007-02-09  John W. Eaton  <jwe@octave.org>
 
 	* plot/subplot.m: Delete spurious call to axes.
--- a/scripts/plot/__uiobject_delete__.m	Sat Feb 10 08:42:27 2007 +0000
+++ b/scripts/plot/__uiobject_delete__.m	Sat Feb 10 16:33:33 2007 +0000
@@ -32,6 +32,8 @@
       if (strcmp (obj.type, "figure"))
 	ps = obj.__plot_stream__;
 	if (any (ps == fopen ("all")))
+	  fputs (ps, "\nquit;\n");
+	  fflush (ps);
 	  pclose (ps);
 	endif
       endif
--- a/scripts/plot/__uiobject_globals__.m	Sat Feb 10 08:42:27 2007 +0000
+++ b/scripts/plot/__uiobject_globals__.m	Sat Feb 10 16:33:33 2007 +0000
@@ -1,7 +1,3 @@
-
-  ## Any function that includes these variables should not be cleared.
-
-  mlock ();
 
   ## The collection of current figure handles.  We need this to be able to
   ## allocate the next unused figure number.
--- a/scripts/plot/drawnow.m	Sat Feb 10 08:42:27 2007 +0000
+++ b/scripts/plot/drawnow.m	Sat Feb 10 16:33:33 2007 +0000
@@ -26,6 +26,13 @@
 
 function drawnow (term, file)
 
+  ## Use this instead of persistent and mlock so that drawnow can be
+  ## replaced.
+  global __uiobject_close_all_registered__;
+  if (isempty (__uiobject_close_all_registered__))
+    __lock_global__ ("__uiobject_close_all_registered__");
+  endif
+
   ## Use this instead of calling gcf to avoid creating a figure.
 
   h = get (0, "currentfigure");
@@ -42,11 +49,15 @@
         cmd = sprintf ("%s -title \"Figure %d\"", cmd, h);
       endif
       plot_stream = popen (cmd, "w");
+      if (isempty (__uiobject_close_all_registered__))
+	atexit ("__uiobject_close_all__");
+	__uiobject_close_all_registered__ = true;
+      endif
       if (plot_stream < 0)
 	error ("drawnow: failed to open connection to gnuplot");
       else
 	set (h, "__plot_stream__", plot_stream);
-	if (isempty (getenv ("DISPLAY")))
+	if (isunix () && isempty (getenv ("DISPLAY")))
 	  fprintf (plot_stream, "set terminal dumb\n;");
 	endif
       endif
@@ -74,5 +85,4 @@
 
   endif
 
-
 endfunction