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 - Access violation in TFastLineSeries.Clear;
Summary: Access violation in TFastLineSeries.Clear;
Status: UNCONFIRMED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Chart (show other bugs)
Version: 37.230130
Hardware: PC Windows
: --- minor
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-17 09:44 EDT by Ton
Modified: 2024-05-17 09:44 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.