I tested win terminal of gp54rc1-win64-mingw.exe, it may crash as reported by Tait.
In the case wgnuplot.ini does not exist, wgnuplot says at setting term win:
Terminal type is now 'windows'
Options are '0 color solid butt enhanced standalone'
and it crashes by simple 'test' command. To specify graph size
'set term win size 640,400' explicitly, then
Terminal type is now 'windows'
Options are '0 color solid butt enhanced standalone size 640,400'
and 'test' command startup graph window correctly.
To save the file wgnuplot.ini on the textwindow, the file don't
include the entry of graph window size. To save on the graphwindow,
the size is saved in the file, but the value may not be correct:
GraphSize=1036037186 -31206
At the next wgnuplot process, 'set term win' says:
Terminal type is now 'windows'
Options are '0 color solid butt enhanced standalone wsize 1036037186,-2147483648'
and it crashes by 'test'.
I think the win terminal has the problem for initialize of graph window size.
Bugs: #2123
Bugs: #2223
Bugs: #2227
Bugs: #2286
Bugs: #2301
Bugs: #2402
This problem may not occur on the binary without '-DHAVE_D2D11' (comment out the line "#DIRECT2D11"). It may be by src/win/wd2d.cpp.
I found one problem in wgraph.c. ReadGraphIni() function open lpgw->hGraph window by CreateWindow() by size lpgw->Size.x - lpgw->Decoration.x, lpgw->Size.y - lpgw->Decoration.y.
But this is incorrect for the case lpgw->Size.x == CW_USEDEFAUT or lpgw->Size.y == CW_USEDEFAULT. In fact, we may avoid to crash the graph window even in the case DIRECT2D11 by attached testing patch, but it may not be correct to use CW_USEDEFAULT for lpgw->hGraph.
And this doesn't fix the problem for saving the window size above. It may be a different problem.
Attached patch is better than wgraph.c-1.diff. This avoids undefined value of lpgw->Canvas.{x,y} and changes lpgw->Size.{x,y} from CW_USEDEFAULT to the real value.
But it also doesn't solve the problem above. The problem occurs for the following commands:
set term win size 900,600 ; plot x ; set term png ; set term win
The last command says " size 119509427,-34734". It doesn't occur by
set term win ; plot x ; set term png ; set term win
and
set term win wsize 900,600 ; plot x set term png ; set term win
This means the value lpgw->Canvas.{x,y} may be incorrect in the last command, but I don't find the point.
I found the point. Attached patch which includes wgraph.c-2.diff may solve the problem above.
Applied, with the exception of the tracking of the Canvas size. That is really only supposed to be non-zero if set via the "set term command". Thanks.
Re-opening this tracker. Either the changes have other side effects, or there are more similar bugs. E.g.
set term win standalone; clear; set term win close; set term win docked; clear
fails to init the drawing area completely.@sfeam, I consider these bugs release-critical for 5.4.2 on Windows.
Please try to use attached patch (lpgw->StatusHeight was calcurated to invalid value).
Thanks for looking into this. There should never be an additional statusbar for the graph when the graph window is "docked", i.e. attached to the text terminal. So for me this doesn't change anything. What is the scenario where this is a problem?
My example above failed for Direct2D 1.1 and above since the graph window never receives a WM_CLOSE. Just a WM_DESTROY. No idea why that is. Now fixed in master branch.
I don't understand the problem on your environment. And I may use different source from you.
I tested gnuplot-5.4.0 with wgraph-3.diff on my Windows10 machine.
On my machine, your command "set term win standalone ..." makes docked graph window, but we can not draw any graph with warning:
warning: Warning - difficulty fitting plot titles into key
This may be a result of incorrect lpgw->StatusHeight at Line 501 of wgraph.c. For example, the value may be 565, then lpgw->Decoration.y will be incorrect large value (Ex.593) calcurate by wrong lpgw->StatusHeight, and the 7th argument lpgw->Size.y - lpgw->Decoration.y of CreateWindow() for lpgw->hGraph (at Line 697) will be negative value (Ex. 541-593). This makes hGraph window with height 0. then, it will occur the problem for MakeFonts() because the rect.bottom = rect.top = 0. This sets lpgw->vchar and lpgw->vtic the value -1, which is the error value of the function MulDiv().
So, on my environment, wgraph.c-4.diff fixed the problem.
Thanks for the info. I still think there is another problem since those conditions (docked and hStatusbar != NULL) should never be true at the same time. The error was due to GraphClose not being called and hence hStatusbar not being set to NULL, which is now fixed. I provide a 5.5 build in files/testing for testing.
@shige-takeno, do you still have issues with version 5.4.2 or can we close this tracker?
The problem seems to be solved in 5.4.2 windows binary. Thanks.
Thank you very much for the feedback.