(Sorry on my english.)
I have also a problem with "Datasource makes a circular link" - but with ZTable1.MasterSource.
I have a similar problem, but with MasterSource.
When I assign the value nil to MasterSource, I also get the error message "Datasource makes a circular link".
I did not have this problem under Lazarus 2.06 with FPC 3.0.4 yet.
The reason seems to be a change from FPC 3.0.4 to FPC 3.2.2.
Error example:
Code: Select all
...
DataModule1.ZTable2.Active := false;
DataModule1.ZTable2.FilterOptions := [foCaseInsensitive];
DataModule1.ZTable2.Filter := 'BEREICH = 1 and BEREICHSID = 0';
DataModule1.ZTable2.Filtered := true;
DataModule1.ZTable2.MasterSource := nil;
DataModule1.ZTable2.LinkedFields := 'BNUMMER';
DataModule1.ZTable2.MasterFields := 'MNUMMER';
DataModule1.ZTable2.MasterSource := DataModule1.DataSource1;
DataModule1.ZTable2.Active := true;
...
The error occurs with
DataModule1.ZTable2.MasterSource := nil;
It works with:
X:\Users\Username\AppData\Local\lazarus\onlinepackagemanager\packages\zeosdbo\src\component\zabstractrodataset.pas
Code: Select all
...
procedure TZAbstractRODataset.SetMasterDataSource(Value: TDataSource);
begin
{$IFNDEF FPC}
if IsLinkedTo(Value) then
{$ELSE}
if Value.IsLinkedTo(Self) then
{$ENDIF}
raise EZDatabaseError.Create(SCircularLink);
MasterLink.DataSource := Value;
RereadRows;
end
...
In the TZAbstractRODataset.SetMasterDataSource function the IsLinkedTo() function is used.
Up to version FPC 3.0.4 this function had the following content:
Code: Select all
Function TDataSource.IsLinkedTo(ADataset: TDataSet): Boolean;
begin
Result:=False;
end;
In the current version FPC 3.2.2 it has the following content:
Code: Select all
Function TDataSource.IsLinkedTo(ADataset: TDataSet): Boolean;
var
DS: TDataSource;
begin
Result:=False;
Repeat
DS:=aDataSet.GetDataSource;
Result:=(DS=Self);
if Assigned(DS) then
aDataSet := DS.DataSet
else
aDataSet := Nil;
Until Result or (aDataSet=Nil)
end;
On the one hand, we work here partly with aDataSet and partly with ADataSet. (Which should not lead to an error with Pascal, because without distinction between upper and lower case).
On the other hand, another - still largely empty - function GetDataSource is referred to:
Code: Select all
function TDataSet.GetDataSource: TDataSource;
begin
Result:=nil;
end;
The IsLinkedTo() function does not work properly in the context of assigning the value nil and leaves any assignment like
DataModule1.ZTable1.MasterSource := nil; result in the above error.
In the meantime I'm thinking about recompiling either zabstractrodataset.pas with deactivation of IsLinkedTo() or working with a copy of ZTable1 (without assignment to MasterSource). However, this results in a lot of unnecessary resources and instructions.
Is it not better here to skip or replace IsLinkedTo() until it works in FPC?