LCL, fix exception caused by dblookup controls opening dataset, from Leslie Kaye, issue #14197

git-svn-id: trunk@21161 -
This commit is contained in:
jesus 2009-08-10 18:10:51 +00:00
parent e5289a924c
commit d43265773b
2 changed files with 16 additions and 4 deletions

View File

@ -151,6 +151,7 @@ Type
procedure LinkGetBookMark;
procedure LinkGotoBookMark;
procedure SetKeyFieldName(const Value: string);
procedure SetListFieldName(const Value: string);
procedure SetListSource(Value: TDataSource);
procedure SetLookupCache(const Value: boolean);
protected
@ -166,7 +167,7 @@ Type
// properties to be published by owner control
// these are not used where data control Field is dbLookup
property KeyField: string read GetKeyFieldName write SetKeyFieldName;
property ListField: string read FListFieldName write FListFieldName;
property ListField: string read FListFieldName write SetListFieldName;
property ListFieldIndex: Integer read FListFieldIndex write FListFieldIndex default 0;
property ListSource: TDataSource read GetListSource write SetListSource;
end;

View File

@ -122,6 +122,12 @@ begin
FKeyFieldNames := Value;
end;
procedure TDBLookup.SetListFieldName(const Value: string);
begin
FListFieldName := Value;
FListLink.FieldName := Value;
end;
procedure TDBLookup.SetListSource(Value: TDataSource);
begin
if FListSource = Value then
@ -249,11 +255,16 @@ begin
if (FKeyFieldNames > '') and Assigned(FListLink.Dataset) then
begin
ListFields := TList.Create;
FListLinkTmpSetActive := not FListLink.DataSet.Active;
if FListLinkTmpSetActive then
try
FListLink.DataSet.Open;
except
FListLinkTmpSetActive := False;
Exit;
end;
ListFields := TList.Create;
try
if FListLinkTmpSetActive then
FListLink.DataSet.Open;
if FListLink.DataSet.Active then
begin
FListLink.DataSet.GetFieldList(ListFields, FListFieldName);