From 6fa24e2bd9604cd37363f42055f80cacc512023f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Fri, 18 Feb 2022 16:41:15 +0100 Subject: [PATCH] * Fixes so it works correctly with FPC 3.2 (NeedFielddefs not properly set) --- components/datadict/fpcodegenerator.pp | 2 + .../datadict/frmbaseconfigcodegenerator.lfm | 45 +++++++++---------- .../datadict/frmbaseconfigcodegenerator.pp | 5 ++- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/components/datadict/fpcodegenerator.pp b/components/datadict/fpcodegenerator.pp index 2dd3a9ccc2..5aba1ef54e 100644 --- a/components/datadict/fpcodegenerator.pp +++ b/components/datadict/fpcodegenerator.pp @@ -107,7 +107,9 @@ Var F : TBaseConfigGeneratorForm; begin +{$IFNDEF VER3_2} If FGenerator.NeedsFieldDefs then +{$ENDIF} begin FP:=FGenerator.Fields; if Assigned(Dataset) then diff --git a/components/datadict/frmbaseconfigcodegenerator.lfm b/components/datadict/frmbaseconfigcodegenerator.lfm index a8c5664471..36514807f7 100644 --- a/components/datadict/frmbaseconfigcodegenerator.lfm +++ b/components/datadict/frmbaseconfigcodegenerator.lfm @@ -9,7 +9,7 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm ClientWidth = 549 OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '2.1.0.0' + LCLVersion = '2.3.0.0' object PGenerator: TPanel Left = 0 Height = 40 @@ -30,15 +30,16 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm Caption = '&Save to' FocusControl = FEFile Layout = tlCenter - ParentColor = False end object FEFile: TFileNameEdit Left = 72 - Height = 29 + Height = 27 Top = 5 Width = 304 - DialogOptions = [] + DialogKind = dkSave + DialogOptions = [ofOverwritePrompt, ofPathMustExist] FilterIndex = 0 + DefaultExt = '.pas' HideDirectories = False ButtonWidth = 23 NumGlyphs = 1 @@ -51,14 +52,14 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm Left = 384 Height = 23 Top = 8 - Width = 147 + Width = 156 Caption = 'Sho&w generated code' TabOrder = 1 end end object PCConf: TPageControl Left = 0 - Height = 287 + Height = 288 Top = 40 Width = 549 ActivePage = TSFields @@ -68,7 +69,7 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm OnChange = PCConfChange object TSFields: TTabSheet Caption = 'Fields' - ClientHeight = 256 + ClientHeight = 258 ClientWidth = 539 object Panel2: TPanel Left = 0 @@ -90,7 +91,6 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm AutoSize = False Caption = 'Fields to generate code for' Layout = tlCenter - ParentColor = False end object LProperties: TLabel Left = 170 @@ -102,22 +102,21 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm AutoSize = False Caption = 'Properties for selected field' Layout = tlCenter - ParentColor = False end end object PFieldList: TPanel Left = 0 - Height = 228 + Height = 230 Top = 28 Width = 170 Align = alLeft BevelOuter = bvNone - ClientHeight = 228 + ClientHeight = 230 ClientWidth = 170 TabOrder = 1 object CLBFields: TCheckListBox Left = 35 - Height = 228 + Height = 230 Top = 0 Width = 135 Align = alClient @@ -130,12 +129,12 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm end object PButtons: TPanel Left = 0 - Height = 228 + Height = 230 Top = 0 Width = 35 Align = alLeft BevelOuter = bvNone - ClientHeight = 228 + ClientHeight = 230 ClientWidth = 35 TabOrder = 1 object SBup: TSpeedButton @@ -320,14 +319,14 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm end object Splitter1: TSplitter Left = 170 - Height = 228 + Height = 230 Top = 28 Width = 5 OnMoved = Splitter1Moved end object GFieldProps: TTIPropertyGrid Left = 175 - Height = 228 + Height = 230 Top = 28 Width = 364 Align = alClient @@ -341,13 +340,13 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm end object TSOptions: TTabSheet Caption = 'Options' - ClientHeight = 256 + ClientHeight = 258 ClientWidth = 539 object GCodeOptions: TTIPropertyGrid Left = 0 - Height = 240 + Height = 258 Top = 0 - Width = 452 + Width = 539 Align = alClient CheckboxForBoolean = False DefaultValueFont.Color = clWindowText @@ -361,11 +360,11 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm end object TSPreview: TTabSheet Caption = 'Preview' - ClientHeight = 256 + ClientHeight = 258 ClientWidth = 539 inline sePreview: TSynEdit Left = 0 - Height = 256 + Height = 258 Top = 0 Width = 539 Align = alClient @@ -867,8 +866,8 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm end object PDlgButtons: TButtonPanel Left = 6 - Height = 39 - Top = 333 + Height = 38 + Top = 334 Width = 537 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True diff --git a/components/datadict/frmbaseconfigcodegenerator.pp b/components/datadict/frmbaseconfigcodegenerator.pp index 80887835a8..6c7c62a202 100644 --- a/components/datadict/frmbaseconfigcodegenerator.pp +++ b/components/datadict/frmbaseconfigcodegenerator.pp @@ -144,12 +144,14 @@ begin can be configured, or all fields. } FreeAndNil(FFieldMap); FFieldMap:=TFieldPropDefs.Create(FGen.Fields.ItemClass); +{$IFNDEF VER3_2} If Not FGen.NeedsFieldDefs then begin PCConf.ActivePage:=TSOptions; TSFields.TabVisible:=False; end else +{$ENDIF} begin S:=TStringList.Create; try @@ -247,6 +249,7 @@ begin begin NewName:=ExtractFileName(FEFile.FileName); FLastName:=NewName; + if NewName='' then NewName:='unit1'; // Strip off known extensions if FilenameExtIn(NewName,['.pas','.pp','.inc','.lpr','.dpr']) then FCodeOptions.UnitName:=ChangeFileExt(NewName,'') @@ -286,7 +289,7 @@ begin sePreview.Lines.BeginUpdate; sePreview.Lines.Clear; CG.CodeOptions.Assign(FCodeOptions); - CG.Fields.Assign(FGen.Fields); + CG.Fields.Assign(FFieldMap); CG.GenerateCode(sePreview.Lines); finally sePreview.Lines.EndUpdate;