# HG changeset patch # User jwe # Date 1171125213 0 # Node ID 4553ff6b7ec74cab71a8aebb58beb45729e231b1 # Parent a943cb9c80684ee381b3ed32230654c8e4e62b64 [project @ 2007-02-10 16:33:33 by jwe] diff -r a943cb9c8068 -r 4553ff6b7ec7 scripts/ChangeLog --- 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 + + * 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 * plot/subplot.m: Delete spurious call to axes. diff -r a943cb9c8068 -r 4553ff6b7ec7 scripts/plot/__uiobject_delete__.m --- 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 diff -r a943cb9c8068 -r 4553ff6b7ec7 scripts/plot/__uiobject_globals__.m --- 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. diff -r a943cb9c8068 -r 4553ff6b7ec7 scripts/plot/drawnow.m --- 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