[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with plotting (Windows)
From: |
John W. Eaton |
Subject: |
Re: Problems with plotting (Windows) |
Date: |
Sat, 10 Feb 2007 11:33:34 -0500 |
On 10-Feb-2007, Michael Goffioul wrote:
| John W. Eaton a écrit :
| > On 10-Feb-2007, Michael Goffioul wrote:
| >
| > | I detected 2 problems in the new plotting system:
| > | - drawnow.m: use "dumb" terminal is DISPLAY variable is not defined;
| > | under Windows, this variable is not defined, so adding a "&& isunix()" in
| > | the test would be OK
| > | - __uiobject_delete__.m: closing the plot stream is not preceeded by a
| > | "quit" statement, to close gnuplot properly; this makes the pclose
statement
| > | to hang indefinitely.
| >
| > OK, I checked in the following changes. Does this help?
| >
|
| Yes, thanks. Howerer, I notice 2 other problems:
| 1) with the patch you sent, figures (and gnuplot) can now be closed
| properly when
| you explicitely call "close". The problem still exists when I exit
| octave while a figure
| is open: it hangs (maybe this problem only occurs under Windows; if
| required, I can
| try to debug it to see where it hangs, but in this case I have to
| recompile everything)
Does the attached patch help?
| 2) some files use "mlock()", especially "get.m". This is a problem when
| I switch to
| another plotting system like octplot, which also includes such function.
| If I switch
| after "get.m" has been executed at least once (for instance by plotting
| something),
| then octplot is unable to overload it (by prepending its own path to the
| load paths),
| because the file is locked. You then end up with octplot calling
| "get.m" from
| gnuplot-based plotting system.
OK, by using mlock, I was trying to avoid having "clear all" delete
the global data used by the plotting system. But mlock doesn't solve
that problem anyway, so I introduced a new internal function
__lock_globals__ and then forgot to remove the mlock. I've removed it
now and the following seems to work:
plot (x, y)
clear all
axis (...) ## or any other command that alters the existing plot,
## so you can see that the plot data is still
## available and subsequent drawnow commands work.
jwe
scripts/ChangeLog:
2007-02-10 John W. Eaton <address@hidden>
* plot/drawnow.m: Arrange for plot streams to be close on exit.
* plot/__uiobject_globals__.m: Don't call mlock.
Index: scripts/plot/__uiobject_globals__.m
===================================================================
RCS file: /cvs/octave/scripts/plot/__uiobject_globals__.m,v
retrieving revision 1.2
diff -u -u -r1.2 __uiobject_globals__.m
--- scripts/plot/__uiobject_globals__.m 30 Jan 2007 19:16:53 -0000 1.2
+++ scripts/plot/__uiobject_globals__.m 10 Feb 2007 16:31:14 -0000
@@ -1,8 +1,4 @@
- ## 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.
Index: scripts/plot/drawnow.m
===================================================================
RCS file: /cvs/octave/scripts/plot/drawnow.m,v
retrieving revision 1.4
diff -u -u -r1.4 drawnow.m
--- scripts/plot/drawnow.m 8 Feb 2007 20:06:55 -0000 1.4
+++ scripts/plot/drawnow.m 10 Feb 2007 16:31:14 -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,6 +49,10 @@
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