I haven’t been able to reproduce the problem with TeeChart Pro v2016.19 and RAD XE or RAD 10.1 Berlin Update 2.
What TeeChart version, IDE and OS version are you using?
I’m using TeeChart Pro v2016.19 and RAD 10.1 Berlin Update 1.
Meanwhile I found out, that the problem does not happen every time.
Sometimes when I start the program I can zoom the chart, then export the image, then unzoom many times without problems, but at any time it happens anyhow.
Some other time the problem occurs immediately after the first attempt.
It happens on other computer too.
I tried to find out some special conditions to produce the error - without success.
When I start the program in the debugger the error occurs in Vcl.Graphics in the procedure TCustomCanvas.Lock.
Hello Yeray,
sorry, indeed I have Update 2 installed on two machines. Strange to say on one machine Update 1 is displayed when I open Help | Info about, allthough the start displays says Update 2.
These are the complete version numbers on both machines:
Delphi 10.1 Berlin Version 24.0.25048.9432
TeeChart Pro v2016.19.161025 32bit VCL
Both machines are running with Windows 10 Pro 64Bit.
The error occurs on both machines.
I see the chart in your video is in 2D and has a gradient in the legend and in the back wall, but these properties may be defined in your dfm because they aren’t in the .pas you pasted in the opening post.
There may be some property you’ve set at design-time that could be relevant here, because I still can’t reproduce the problem here.
So, could you please attach the test project so we can reproduce the problem here?
Thanks in advance.
I could reproduce the problem with v2016.19 but it seems to work fine with the current sources we have here.
Since the compiled packages for Berlin are quite big (about 1.5Gb), if you are only interested on win32 I can send you a prerelease version of those binaries. If you need another personality I’m afraid you should wait until we publish the next maintenance release (expected at the beginning March).
Hello Yeray,
I’m a little relieved that you could reproduce the problem.
There is no hurry for an interim solution, so I’ll wait for your next release in March.
I’ve run the test application you sent here several times using TChart v2017.21. One time it crashed but not the rest of the times.
So it seems I can’t reproduce the problem in a consistent basis.
I have been able to reproduce the problem with some regularity.
It seems to relate to a problem with the Canvas handle after it has been used for JPEG creation and then ‘use returned to’ the Chart for conventional canvas use, the problem aggravated when XOr is-being/has-been used to plot zoom rectangle.
This code resolves the problem in initial tests:
procedure TForm1.ExportBtnClick(Sender: TObject);
var
FName: string;
OldCanvas : TCanvas;
begin
OldCanvas := Chart1.Canvas.ReferenceCanvas;
SavePictureDialog1.Filter := 'JPG-Datei (*.jpg)|*.jpg';
if not SavePictureDialog1.Execute then Exit;
FName := SavePictureDialog1.FileName;
if ExtractFileExt(FName) = '' then FName := FName + '.jpg';
with GetChartJPEG(Chart1) do begin
SaveToFile(FName); { <-- save the JPEG to disk }
Free; { <-- free the temporary JPEG object }
end;
Chart1.Canvas.ReferenceCanvas := OldCanvas;
end;
I’m not sure whether we can build the fix into the Chart itself (some kind of check) as the check itself on the Canvas.Handle could AV due to the invalid allocation. The code lines above are seem resilient so far.
We’ll check whether there might be other, negative side effects if we build the modification into TeeChart’s own export code.