Page 1 of 1

buggy TCustomDBChart.CheckNewDataSource

Posted: Fri Jun 11, 2004 6:46 am
by 8573792
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

Posted: Fri Jun 11, 2004 1:51 pm
by Marjan
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).

Posted: Wed Jun 16, 2004 8:58 am
by 8573792
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