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 2463

Summary: EInvalidPointer "Invalid pointer operation" exception when trying to remove a custom label from an axis
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: AxisAssignee: yeray alonso <yeray>
Status: RESOLVED FIXED    
Severity: enhancement CC: yeray
Priority: ---    
Version: 32.210430   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description yeray alonso 2021-10-08 09:48:00 EDT
Trying to delete a custom label from an axis, using Delete(Index) method, raises an "Invalid pointer operation" exception.
This happens in new IDEs (tested in RAD 10.2 Tokyo and 11 Alexandria), but works fine in old ones (tested in RAD XE).

Ie:

procedure TForm1.Button1Click(Sender: TObject);
begin
  with Chart1.Axes.Bottom do
    if Items.Count>0 then
    begin
      //Invalid pointer operation:
      Items.Delete(0);
      //Items[0].Destroy;

      //Working without errors:
      //TList<TAxisItem>(Items).Delete(0);
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  //Working without errors:
  Chart1.Axes.Bottom.Items.Clear;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Label1.Caption:='Number of bottom axis items: ' + (IntToStr(Chart1.Axes.Bottom.Items.Count));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption:=TeeMsg_Version;

  Chart1.Axes.Bottom.Items.Add(2,'Dog');
  Chart1.Axes.Bottom.Items.Add(3,'Cat');
  Chart1.Axes.Bottom.SetMinMax(0, 5);
end;