problem with TPieSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Wysu
Newbie
Newbie
Posts: 21
Joined: Wed Apr 27, 2005 4:00 am

problem with TPieSeries

Post by Wysu » Fri Oct 26, 2007 4:15 pm

With Delphi 7 and Teechart Pro 7.12.
I have a Teechart with TPieSeries in my application and I get an access violation on the application exit.

my serie creation:

Chart1.SeriesList.Clear;
tmpSeries := TPieSeries.Create(Chart1);
TPieSeries(tmpSeries).Circled := true;
tmpSeries.ParentChart := Chart1;
tmpSeries.Add(10,'bob', clBlue);
tmpSeries.Add(25,'brico', clOlive);

I think it lacks a simple initialization or else but I'm unable to find what is it. Can someone help me?

Wysu
Newbie
Newbie
Posts: 21
Joined: Wed Apr 27, 2005 4:00 am

Post by Wysu » Mon Oct 29, 2007 10:11 am

Seems like I must use Chart1.FreeAllSeries instead of Chart1.serieList.clear because TChartSeriesList doesn't override the TList Clear procedure (so it just free the list's Items but FreeAllSeries set every series parentChart attribute to nil).

I try to add :

procedure TChartSeriesList.Clear;
var t : Integer;
begin
for t:=0 to Count-1 do Items[t].ParentChart:=nil;
inherited;
end;

in TeEngine.pas and it seems I have no longer AVs...
It would be nice if someone could check this. Thanks.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Nov 05, 2007 12:04 pm

Hi,

yes, the best way would be to do :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var tmpSeries: TPieSeries;
begin
  Chart1.FreeAllSeries(nill);
  tmpSeries := TPieSeries.Create(Chart1);
  TPieSeries(tmpSeries).Circled := true;
  tmpSeries.ParentChart := Chart1;
  tmpSeries.Add(10,'bob', clBlue);
  tmpSeries.Add(25,'brico', clOlive);
end;
Using it I don't get AV's here.

Post Reply