Page 1 of 1

problem with TPieSeries

Posted: Fri Oct 26, 2007 4:15 pm
by 9341766
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?

Posted: Mon Oct 29, 2007 10:11 am
by 9341766
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.

Posted: Mon Nov 05, 2007 12:04 pm
by Pep
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.