bugGNU Octave - Bugs: bug #58408, closing gnuplot windows without...

 
 

bug #58408: closing gnuplot windows without "close" makes other toolkits unusable

Submitter:  Daniel Molina García <dmolina>
Submitted:  Wed 20 May 2020 05:39:33 AM UTC
   
 
Category:  Plotting with gnuplot Severity:  2 - Minor
Priority:  2 Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 20 May 2020 04:12:41 PM UTC, comment #8: 

As Markus says, the problem is that Octave uses a pipe for communication with gnuplot in a different process and this communication is basically one way.  The Octave side, which maintains a list of active figures, doesn't know the figure has been removed unless it was removed on the Octave side using close().

Here is the diary from a test I ran


octave:52> close all
octave:53> graphics_toolkit qt
octave:54> figure ("deletefcn", @() disp ("Deleting figure"))
## I closed figure window with 'X'
octave:55> Deleting figure

octave:55> graphics_toolkit gnuplot
octave:56> figure ("deletefcn", @() disp ("Deleting figure"))
## I closed figure window with 'X'
## Figure is gone, but no message printed
octave:57> close (1)
Deleting figure
octave:58>
## Now message is printed after I use Octave to close figure.



Rik <rik5>
Group administrator
Wed 20 May 2020 04:08:58 PM UTC, comment #7: 

@Rik: The commands in comment #4 work because they create new figures and allow the "ghost" gnuplot figures to remain in limbo.
"plot" on the other hand uses the current figure if one exists.

Markus Mützel <mmuetzel>
Group administrator
Wed 20 May 2020 04:06:50 PM UTC, comment #6: 

Sorry. The second example should have been:

graphics_toolkit ("gnuplot");
hf_gnuplot = figure (3);
line ();


Followed by:

figure (3);
hold on


Markus Mützel <mmuetzel>
Group administrator
Wed 20 May 2020 04:05:16 PM UTC, comment #5: 

AFAIU, the windows that are created with the gnuplot toolkit are "out of control" of Octave. There is no way of knowing how large they are or if they are even closed.
E.g. create a handle to figures with the "qt" and with the "gnuplot" toolkit:

graphics_toolkit ("qt"); hf_qt = figure (1);
graphics_toolkit ("gnuplot"); hf_gnuplot = figure (2);


Now close both figures (using the mouse) and check if the handles are still valid:

>> ishghandle (hf_qt)
ans = 0
>> ishghandle (hf_gnuplot)
ans = 1


Or another example:

graphics_toolkit ("gnuplot");
hf_gnuplot = figure (2);
line ();


A gnuplot figure with a line should appear on screen.
Now close the window with the mouse and issue the following commands:

figure (3);
hold on


The figure reappears with the previous content. As far as Octave knows, the window was never closed.

I don't know if there is anything we can do about this.
The communication with gnuplot is basically one way only.

Markus Mützel <mmuetzel>
Group administrator
Wed 20 May 2020 03:53:41 PM UTC, comment #4: 

There seems to be some difference between plot() and figure().  With figure(), things works correctly.  My guess is that plot() is somehow bypassing an essential check when it creates the figure.

Example that works:


close all
graphics_toolkit qt
figure ()
## Close figure with 'X' on menubar
graphics_toolkit gnuplot
figure ()
## Close figure with 'X' on menubar
graphics_toolkit fltk
figure ()



Rik <rik5>
Group administrator
Wed 20 May 2020 03:46:51 PM UTC, comment #3: 

Regarding comment #1, this is expected.  "graphics_toolkit" affects new figure windows, not existing ones unless you explictly name the windows.  For example,


graphics_toolkit (gcf, 'fltk')


will switch only the current figure window to use FLTK, but any new figures will continue to use whatever the default graphics toolkit is.  This behavior is required for Matlab compatibility.

Rik <rik5>
Group administrator
Wed 20 May 2020 03:44:21 PM UTC, comment #2: 

Confirmed.

That is very odd.  Incidentally, I can cause the correct behavior by switching the toolkit back to gnuplot, opening a figure, and then using "close" to properly shut the figure down.

Rik <rik5>
Group administrator
Wed 20 May 2020 05:53:40 AM UTC, comment #1: 

By the way, for every graphics_toolkit, if windows are left open before calling "plot" then used toolkit is the one of the open window instead of what graphics_toolkit indicates. I do not know if that is expected or not.

Daniel Molina García <dmolina>
Wed 20 May 2020 05:39:33 AM UTC, original submission:  

I reproduced it in development version and 5.2.

Commands graphics_toolkit("qt") and graphics_toolkit("fltk") work as expected. However, once graphics_toolkit("gnuplot") is introduced, the former two commands have no effect when plotting if plot is closed using the environment (e.g., pressing 'x' in the top corner or ALT+F4). It is, even if graphics_toolkit print the expected toolkit, the window appearing is always gnuplot's one.

It does not happen if gnuplot windows are closed by using "close".

Example to reproduce it:

octave:1> x=0:0.1:10; y=sin(x);
octave:2> plot(x,y) # qt window appear. Close window pressing "x" or Alt+F4.
octave:3> graphics_toolkit("fltk")
octave:4> plot(x,y) # fltk window appear. Close window pressing "x" or Alt+F4.
octave:5> graphics_toolkit("gnuplot")
octave:6> plot(x,y) # gnuplot window appear. Close window pressing "x" or Alt+F4.
octave:7> graphics_toolkit("fltk")
octave:8> plot(x,y) # gnuplot window appear. Close window pressing "x" or Alt+F4.
octave:9> graphics_toolkit
ans = fltk
octave:10> graphics_toolkit("qt")
octave:11> plot(x,y) # gnuplot window appear. Close window pressing "x" or Alt+F4.
octave:12> graphics_toolkit
ans = qt

Daniel Molina García <dmolina>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dmolina (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-20 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 2
        Release6.0.90 dev
    2020-05-20 rik5 Item GroupNone Incorrect Result
        StatusNone Confirmed
        Releasedev 6.0.90

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code