buggy TCustomDBChart.CheckNewDataSource

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Lucian
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: Romania
Contact:

buggy TCustomDBChart.CheckNewDataSource

Post by Lucian » Fri Jun 11, 2004 6:46 am

Hi,

The method is faulty because it increases the IDataSources.Count every time it is called. The item added to the list is of type TDBChartDataSource and created local, and so, searching the input parameter ADataSet will always fail, thus the method will add another item to the list.

I added the following code at the beginning of the method and my problem is gone, can you guys check and more important fix this in v7, in case it was not yet fixed

for I := 0 to IDataSources.Count - 1 do
if TDBChartDataSource(IDataSources).Dataset = ADataset then
Exit;


regards,

Lucian

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Fri Jun 11, 2004 1:51 pm

Hi, Lucien.

I think the

Code: Select all

if IDataSources.IndexOf(ADataSet)=-1 then
more less does the same thing i.e. the code below is executed only if DataSet is not in the IDataSources list (using the v7.0 sources).
Marjan Slatinek,
http://www.steema.com

Lucian
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: Romania
Contact:

Post by Lucian » Wed Jun 16, 2004 8:58 am

Hi Marjan,

The code mentioned does not explain at all how the problem was fixed in v7, on the contrary. Since I do not have v7 code (yet), all I can say is, if the code is the same as it is in v6, the method will continue to be faulty. Can you please post the entire method?

any method like the one below will always fail to find the input parameter (t).

procedure abc(t: A);
var
v: B;
begin
if CollectionOfB.IndexOf(t) = -1 then // --> WILL ALWAYS BE -1
begin
v := B.Create;
......
CollectionOfB.Add(v);
end;
end;

regards,

Lucian

Post Reply