[fpc-devel] Duplicate code in TDatasource.DistributeEvent implementation

Michael Van Canneyt michael at freepascal.org
Sun May 8 11:31:21 CEST 2005



On Sat, 7 May 2005, Luiz Américo wrote:

> take a look at TDatasource.DistributeEvent implementation (datasource.inc):
> 
> With FDatalinks do
> begin
> For I:=0 to Count-1 do
> With TDatalink(Items[i]) do
> If Not VisualControl Then
>      DataEvent(Event,Info);
> For I:=0 to Count-1 do
> With TDatalink(Items[i]) do
> If VisualControl Then
>      DataEvent(Event,Info);
> end;
> 
> Am I missimg something or the check to VisualControl doesnt make sense?
> As far as i can see the code below has the same effect
> 
> With FDatalinks do
> begin
> For I:=0 to Count-1 do
> With TDatalink(Items[i]) do
>    DataEvent(Event,Info);
> end;

No. First non visual components (such as detail datasets, lookup datasets) 
must get their event, and only then visual controls get an event. 

The double loop is intentional.

Michael.


More information about the fpc-devel mailing list