help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnuplot zoom not functioning anymore in octave 2.9.10


From: Daniel J Sebald
Subject: Re: gnuplot zoom not functioning anymore in octave 2.9.10
Date: Sun, 08 Apr 2007 21:46:06 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

Ethan A Merritt wrote:
On Sunday 08 April 2007 13:36, Petr Mikulik wrote:


octave does no longer use temporary data files but switched to inline data. That's a nice improvement. Unfortunately, gnuplot
ignores "replot" for plots with "-", and consequently mousing+hotkeys do
not work.

Thus, it looks like a strong demand to gnuplot developers to implement
replot for "-". This matter was discussed recently, see below...

Does somebody know how to implement it?


I am looking into it, but would appreciate help.  See below in particular.


Will need to consider the behavior. I think "replot" reloading regular files, e.g., 'foo.dat' is sort of convenient. That is, a person runs some outside app to create a new set of data and then simply types "replot". So, should it be automatic reload for disk files and no automatic reload for input streams? If so, will need to have a variable indicating replot vs plot and a variable indicating '-' vs. 'foo.dat'. Or should there be some new option setting for gnuplot "automatic reload off/on"?


The first thing that is needed is to change the order of allocating/freeing
the plot structures in eval_plots().  If we are to use the previously stored
data values, they must not be freed until an entirely new plot command replaces them. Right now the plot structures are freed immediately after drawing the plot. We must change this so that they are freed only on re-entry to eval_plots(). There is a comment at the head of the routine
that suggests somebody tried this and ran into problems:

    /* Reset first_plot. This is usually done at the end of this function.
     * If there is an error within this function, the memory is left allocated,
     * since we cannot call cp_free if the list is incomplete. Making sure that
     * the list structure is always valid requires some rewriting */

I have prepared and attached a patch that switches the calls to cp_free()
from late in the routine to the front (where the above comment now sits).
The comment seems to warn this will break things if there is an inconvenient
int_error() from the plot command.

Well, the patch could probably be moved into CVS right away as it seems like a memory leak and what you've done is a fairly safe way of programming. (BTW, where is first_plot assigned? I don't see that immediately.) It's safe right now because there is no conditional and memory is always freed at that point if some was assigned.

But the issue with regard to replotting and retaining the plot structure with data (which isn't to be reloaded) is just what the above message says. If there is a failure along the way, the plot pointer is valid, but the information in the structure may not be valid.

Eventually there will be a conditional along the way like "if replot don't free memory, but if plot then free memory". So, I would suggest a couple pointers here, one a "temporary" pointer (first_plot_temp) but still static, and one a static global pointer (first_plot). Something like (haven't though this through and I'm not really what exactly "first_plot" means, but it should get the concept across):

  if (first_plot && auto_reload) {
    cp_free(first_plot);
    first_plot = NULL;
  }

  if (!first_plot)

    if (first_plot_temp) {
      cp_free(first_plot_temp);
      first_plot_temp = NULL;
    }

    [snip, get_data()?]

    first_plot = first_plot_temp;
    first_plot_temp = NULL;
  }

Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]