From d43265773baa60b1f5ee6e6843b44ed208128578 Mon Sep 17 00:00:00 2001 From: jesus Date: Mon, 10 Aug 2009 18:10:51 +0000 Subject: [PATCH] LCL, fix exception caused by dblookup controls opening dataset, from Leslie Kaye, issue #14197 git-svn-id: trunk@21161 - --- lcl/dbctrls.pp | 3 ++- lcl/include/dblookup.inc | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lcl/dbctrls.pp b/lcl/dbctrls.pp index a6e84c0b9d..dccd0d505f 100644 --- a/lcl/dbctrls.pp +++ b/lcl/dbctrls.pp @@ -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; diff --git a/lcl/include/dblookup.inc b/lcl/include/dblookup.inc index c3adbbe8f4..a6edef5513 100644 --- a/lcl/include/dblookup.inc +++ b/lcl/include/dblookup.inc @@ -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);