Skip to content

Reap GNUplot temporary files when they are no longer required

Adrian Knagg-Baugh requested to merge gplot_cb into master

Use a thread-based watcher to wait for specific messages printed to GNUplot stderr and either exit GNUplot or clean up the specified temporary file.

GNUplot can be closed and all temporary files deleted by calling gnuplot_close(). This is now safe and will not close GNUplot before the plotting has finished, because the GNUplot print command used to trigger the closure does not start until the preceding plot command is complete. This also means we can always call GNUplot with the --persist option and get rid of the gnuplot close-in-idle function. To remove a specified temporary file, call gnuplot_rmtmpfile(handle, filename) If the temporary file count drops to 0, GNUplot is closed from the watcher thread. (Is this the correct behaviour?)

I've added calls to gnuplot_rmtmpfile() to the commands like gnuplot_plotxy() etc. which are intended simply to make a plot and clean up after themselves: I haven't altered anything else, so if you're using commands like gnuplot_plot_xyyerr_from_datfile() and handling the GNUplot dat file yourself, you'll need to clean it up using gnuplot_rmtmpfile() yourself..

Edited by Adrian Knagg-Baugh

Merge request reports