lcl: prevent loop in TDBLookup.Initialize after changing ListLink.Datasource

git-svn-id: trunk@37057 -
This commit is contained in:
blikblum 2012-04-28 12:39:08 +00:00
parent 4b7489f68f
commit 437c6649fb
2 changed files with 13 additions and 8 deletions

View File

@ -134,6 +134,7 @@ Type
FLookUpFieldIsCached: Boolean;
FLookupCache: boolean;
procedure ActiveChange(Sender: TObject);
procedure ChangeListLinkDataSource(NewDataSource: TDataSource);
procedure EditingChange(Sender: TObject);
procedure FetchLookupData;
function GetKeyFieldName: string;

View File

@ -88,6 +88,16 @@ begin
Initialize(FControlLink, FControlItems);
end;
procedure TDBLookup.ChangeListLinkDataSource(NewDataSource: TDataSource);
begin
if NewDataSource <> FListLink.DataSource then
begin
FListLink.OnActiveChange := nil;
FListLink.DataSource := NewDataSource;
FListLink.OnActiveChange := @ActiveChange;
end;
end;
procedure TDBLookup.EditingChange(Sender: TObject);
begin
if FListLink.Active and not (FListLink.Editing) then
@ -252,21 +262,16 @@ begin
FLookupSource := TDataSource.Create(Self);
if (FLookupSource.DataSet <> FControlLink.Field.LookupDataSet) then
FLookupSource.DataSet:= FControlLink.Field.LookupDataSet;
if FListLink.DataSource <> FLookupSource then
FListLink.DataSource := FLookupSource;
ChangeListLinkDataSource(FLookupSource);
FDataFieldNames := FControlLink.Field.KeyFields;
FKeyFieldNames := FControlLink.Field.LookupKeyFields;
end else
FDataFieldNames := FControlLink.Field.FieldName;
FDataFields.Clear;
FControlLink.DataSet.GetFieldList(FDataFields, FDataFieldNames);
end;
end;
if not FHasLookUpField then
begin
if FListLink.DataSource <> FListSource then
FListLink.DataSource := FListSource;
end;
ChangeListLinkDataSource(FListSource);
if (FKeyFieldNames > '') and Assigned(FListLink.Dataset) then
begin
@ -282,7 +287,6 @@ begin
try
if FListLink.DataSet.Active then
begin
FKeyFields.Clear;
FListLink.DataSet.GetFieldList(ListFields, FListFieldName);
FListLink.DataSet.GetFieldList(FKeyFields, FKeyFieldNames);
if FHasLookUpField then