Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2706

Summary: Access violation in TFastLineSeries.Clear;
Product: VCL TeeChart Reporter: Ton <t.buurstede>
Component: ChartAssignee: Steema Issue Manager <issuemanager>
Status: UNCONFIRMED ---    
Severity: minor CC: yeray
Priority: ---    
Version: 37.230130   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description Ton 2024-05-17 09:44:00 EDT
When using a TChart component in a FastReport report design an Access Violation in TFastLineSeries.Clear occurs when hovering over the embedded TChart component and subsequntly leaving it.

Original code:

procedure TFastLineSeries.Clear;
begin
  inherited;
  if (ParentChart <> nil) and (ParentChart.Canvas <> nil)
  {$IFNDEF FMX}
     and (ParentChart.Canvas.ReferenceCanvas.HandleAllocated)
  {$ENDIF}
  then
    With ParentChart,Canvas do
    begin
        OldX := GetVertAxis.PosAxis; //LeftAxis.PosAxis;
        OldY := GetHorizAxis.PosAxis; //BottomAxis.PosAxis;
        if View3D then MoveTo3D(OldX,OldY,MiddleZ)
                  else MoveTo(OldX,OldY);
    end;
end;

Changed code to avoid the access violation:

procedure TFastLineSeries.Clear;
begin
  inherited;
  if not Assigned(ParentChart) then
    Exit;
  if not Assigned(ParentChart.Canvas) then
    Exit;
  {$IFNDEF FMX}
  if not Assigned(ParentChart.Canvas.ReferenceCanvas) then
    Exit;
  if not ParentChart.Canvas.ReferenceCanvas.HandleAllocated then
    Exit;
  {$ENDIF}
  OldX := GetVertAxis.PosAxis; //LeftAxis.PosAxis;
  OldY := GetHorizAxis.PosAxis; //BottomAxis.PosAxis;
  if ParentChart.View3D then ParentChart.Canvas.MoveTo3D(OldX,OldY,MiddleZ)
            else ParentChart.Canvas.MoveTo(OldX,OldY);
end;

An extra check of ParentChart.Canvas.ReferenceCanvas avoids the exception.