* Fixes so it works correctly with FPC 3.2 (NeedFielddefs not properly set)

This commit is contained in:
Michaël Van Canneyt 2022-02-18 16:41:15 +01:00
parent 81f2319e01
commit 6fa24e2bd9
3 changed files with 28 additions and 24 deletions

View File

@ -107,7 +107,9 @@ Var
F : TBaseConfigGeneratorForm; F : TBaseConfigGeneratorForm;
begin begin
{$IFNDEF VER3_2}
If FGenerator.NeedsFieldDefs then If FGenerator.NeedsFieldDefs then
{$ENDIF}
begin begin
FP:=FGenerator.Fields; FP:=FGenerator.Fields;
if Assigned(Dataset) then if Assigned(Dataset) then

View File

@ -9,7 +9,7 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
ClientWidth = 549 ClientWidth = 549
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
LCLVersion = '2.1.0.0' LCLVersion = '2.3.0.0'
object PGenerator: TPanel object PGenerator: TPanel
Left = 0 Left = 0
Height = 40 Height = 40
@ -30,15 +30,16 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
Caption = '&Save to' Caption = '&Save to'
FocusControl = FEFile FocusControl = FEFile
Layout = tlCenter Layout = tlCenter
ParentColor = False
end end
object FEFile: TFileNameEdit object FEFile: TFileNameEdit
Left = 72 Left = 72
Height = 29 Height = 27
Top = 5 Top = 5
Width = 304 Width = 304
DialogOptions = [] DialogKind = dkSave
DialogOptions = [ofOverwritePrompt, ofPathMustExist]
FilterIndex = 0 FilterIndex = 0
DefaultExt = '.pas'
HideDirectories = False HideDirectories = False
ButtonWidth = 23 ButtonWidth = 23
NumGlyphs = 1 NumGlyphs = 1
@ -51,14 +52,14 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
Left = 384 Left = 384
Height = 23 Height = 23
Top = 8 Top = 8
Width = 147 Width = 156
Caption = 'Sho&w generated code' Caption = 'Sho&w generated code'
TabOrder = 1 TabOrder = 1
end end
end end
object PCConf: TPageControl object PCConf: TPageControl
Left = 0 Left = 0
Height = 287 Height = 288
Top = 40 Top = 40
Width = 549 Width = 549
ActivePage = TSFields ActivePage = TSFields
@ -68,7 +69,7 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
OnChange = PCConfChange OnChange = PCConfChange
object TSFields: TTabSheet object TSFields: TTabSheet
Caption = 'Fields' Caption = 'Fields'
ClientHeight = 256 ClientHeight = 258
ClientWidth = 539 ClientWidth = 539
object Panel2: TPanel object Panel2: TPanel
Left = 0 Left = 0
@ -90,7 +91,6 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
AutoSize = False AutoSize = False
Caption = 'Fields to generate code for' Caption = 'Fields to generate code for'
Layout = tlCenter Layout = tlCenter
ParentColor = False
end end
object LProperties: TLabel object LProperties: TLabel
Left = 170 Left = 170
@ -102,22 +102,21 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
AutoSize = False AutoSize = False
Caption = 'Properties for selected field' Caption = 'Properties for selected field'
Layout = tlCenter Layout = tlCenter
ParentColor = False
end end
end end
object PFieldList: TPanel object PFieldList: TPanel
Left = 0 Left = 0
Height = 228 Height = 230
Top = 28 Top = 28
Width = 170 Width = 170
Align = alLeft Align = alLeft
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 228 ClientHeight = 230
ClientWidth = 170 ClientWidth = 170
TabOrder = 1 TabOrder = 1
object CLBFields: TCheckListBox object CLBFields: TCheckListBox
Left = 35 Left = 35
Height = 228 Height = 230
Top = 0 Top = 0
Width = 135 Width = 135
Align = alClient Align = alClient
@ -130,12 +129,12 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
end end
object PButtons: TPanel object PButtons: TPanel
Left = 0 Left = 0
Height = 228 Height = 230
Top = 0 Top = 0
Width = 35 Width = 35
Align = alLeft Align = alLeft
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 228 ClientHeight = 230
ClientWidth = 35 ClientWidth = 35
TabOrder = 1 TabOrder = 1
object SBup: TSpeedButton object SBup: TSpeedButton
@ -320,14 +319,14 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
end end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 170 Left = 170
Height = 228 Height = 230
Top = 28 Top = 28
Width = 5 Width = 5
OnMoved = Splitter1Moved OnMoved = Splitter1Moved
end end
object GFieldProps: TTIPropertyGrid object GFieldProps: TTIPropertyGrid
Left = 175 Left = 175
Height = 228 Height = 230
Top = 28 Top = 28
Width = 364 Width = 364
Align = alClient Align = alClient
@ -341,13 +340,13 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
end end
object TSOptions: TTabSheet object TSOptions: TTabSheet
Caption = 'Options' Caption = 'Options'
ClientHeight = 256 ClientHeight = 258
ClientWidth = 539 ClientWidth = 539
object GCodeOptions: TTIPropertyGrid object GCodeOptions: TTIPropertyGrid
Left = 0 Left = 0
Height = 240 Height = 258
Top = 0 Top = 0
Width = 452 Width = 539
Align = alClient Align = alClient
CheckboxForBoolean = False CheckboxForBoolean = False
DefaultValueFont.Color = clWindowText DefaultValueFont.Color = clWindowText
@ -361,11 +360,11 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
end end
object TSPreview: TTabSheet object TSPreview: TTabSheet
Caption = 'Preview' Caption = 'Preview'
ClientHeight = 256 ClientHeight = 258
ClientWidth = 539 ClientWidth = 539
inline sePreview: TSynEdit inline sePreview: TSynEdit
Left = 0 Left = 0
Height = 256 Height = 258
Top = 0 Top = 0
Width = 539 Width = 539
Align = alClient Align = alClient
@ -867,8 +866,8 @@ object BaseConfigGeneratorForm: TBaseConfigGeneratorForm
end end
object PDlgButtons: TButtonPanel object PDlgButtons: TButtonPanel
Left = 6 Left = 6
Height = 39 Height = 38
Top = 333 Top = 334
Width = 537 Width = 537
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True

View File

@ -144,12 +144,14 @@ begin
can be configured, or all fields. } can be configured, or all fields. }
FreeAndNil(FFieldMap); FreeAndNil(FFieldMap);
FFieldMap:=TFieldPropDefs.Create(FGen.Fields.ItemClass); FFieldMap:=TFieldPropDefs.Create(FGen.Fields.ItemClass);
{$IFNDEF VER3_2}
If Not FGen.NeedsFieldDefs then If Not FGen.NeedsFieldDefs then
begin begin
PCConf.ActivePage:=TSOptions; PCConf.ActivePage:=TSOptions;
TSFields.TabVisible:=False; TSFields.TabVisible:=False;
end end
else else
{$ENDIF}
begin begin
S:=TStringList.Create; S:=TStringList.Create;
try try
@ -247,6 +249,7 @@ begin
begin begin
NewName:=ExtractFileName(FEFile.FileName); NewName:=ExtractFileName(FEFile.FileName);
FLastName:=NewName; FLastName:=NewName;
if NewName='' then NewName:='unit1';
// Strip off known extensions // Strip off known extensions
if FilenameExtIn(NewName,['.pas','.pp','.inc','.lpr','.dpr']) then if FilenameExtIn(NewName,['.pas','.pp','.inc','.lpr','.dpr']) then
FCodeOptions.UnitName:=ChangeFileExt(NewName,'') FCodeOptions.UnitName:=ChangeFileExt(NewName,'')
@ -286,7 +289,7 @@ begin
sePreview.Lines.BeginUpdate; sePreview.Lines.BeginUpdate;
sePreview.Lines.Clear; sePreview.Lines.Clear;
CG.CodeOptions.Assign(FCodeOptions); CG.CodeOptions.Assign(FCodeOptions);
CG.Fields.Assign(FGen.Fields); CG.Fields.Assign(FFieldMap);
CG.GenerateCode(sePreview.Lines); CG.GenerateCode(sePreview.Lines);
finally finally
sePreview.Lines.EndUpdate; sePreview.Lines.EndUpdate;