From 63f09fd4cde7e69f4f34f37cf47505bb85205c56 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 19 Aug 2010 13:49:03 +0000 Subject: [PATCH] IDE: fixed save/load build macro values git-svn-id: trunk@27148 - --- ide/compileroptions.pp | 12 +----- ide/compileroptionsdlg.pp | 10 ++++- ide/compoptsmodes.pas | 16 ++++++-- ide/frames/compiler_buildmacro_options.lfm | 1 - ide/frames/compiler_buildmacro_options.pas | 43 +++++++++++----------- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 0d30b3356d..c22eeaca07 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -67,7 +67,6 @@ any conditionals ToDo: - - fix bug: opening package compiler options marks package as modified - use conditionals to extend paths - use conditionals to extend usage paths - move the project target file to compiler options @@ -138,7 +137,6 @@ type procedure SaveToXMLConfig(aXMLConfig: TXMLConfig; const Path: string; UsePathDelim: TPathDelimSwitch); procedure CreateDiff(OtherMode: TLazBuildMacro; Tool: TCompilerDiffTool); - procedure Assign(Source: TIDEBuildMacro); procedure IncreaseChangeStamp; property ChangeStamp: integer read FChangeStamp; end; @@ -3634,7 +3632,7 @@ end; procedure TIDEBuildMacro.SetValues(const AValue: TStrings); begin - if (FValues=AValue) or AValue.Equals(AValue) then exit; + if (FValues=AValue) or FValues.Equals(AValue) then exit; FValues.Assign(AValue); IncreaseChangeStamp; end; @@ -3708,14 +3706,6 @@ begin Tool.AddStringsDiff('ValueDescriptions',ValueDescriptions,OtherMode.ValueDescriptions); end; -procedure TIDEBuildMacro.Assign(Source: TIDEBuildMacro); -begin - Identifier:=Source.Identifier; - Values:=Source.Values; - Description:=Source.Description; - ValueDescriptions:=Source.ValueDescriptions; -end; - procedure TIDEBuildMacro.IncreaseChangeStamp; begin if FChangeStamp=High(FChangeStamp) then diff --git a/ide/compileroptionsdlg.pp b/ide/compileroptionsdlg.pp index 5d700aa985..c6b5ddfc03 100644 --- a/ide/compileroptionsdlg.pp +++ b/ide/compileroptionsdlg.pp @@ -783,7 +783,7 @@ begin // conditionals + build macros {$IFDEF EnableBuildModes} - BuildMacrosFrame.Options:=Options; + BuildMacrosFrame.LoadFromOptions(Options); {$ENDIF} // inherited tab @@ -1085,7 +1085,9 @@ begin Options.CompilerMessages.Assign(TempMessages); // conditionals - // these are all done via the frames + {$IFDEF EnableBuildModes} + BuildMacrosFrame.SaveToOptions(Options); + {$ENDIF} // other Options.DontUseConfigFile := not chkConfigFile.Checked; @@ -1146,6 +1148,10 @@ begin // check for change and mark as modified if not OldCompOpts.IsEqual(Options) then begin + //Diff:=TStringList.Create; + //options.CreateDiff(OldCompOpts,Diff); + //debugln(Diff.Text); + //Diff.Free; Options.Modified:=true; IncreaseCompilerParseStamp; end; diff --git a/ide/compoptsmodes.pas b/ide/compoptsmodes.pas index 350f44f26b..9ce44cb89b 100644 --- a/ide/compoptsmodes.pas +++ b/ide/compoptsmodes.pas @@ -133,10 +133,20 @@ procedure TCompilerDiffTool.AddStringsDiff(const PropertyName: string; const OldList, NewList: TStrings); var i: Integer; + OldCnt: Integer; + NewCnt: Integer; begin - AddDiff(PropertyName+'/Count',OldList.Count,NewList.Count); - for i:=0 to OldList.Count-1 do begin - if (i>=NewList.Count) or (OldList[i]<>NewList[i]) then + OldCnt:=0; + if OldList<>nil then + OldCnt:=OldList.Count; + NewCnt:=0; + if NewList<>nil then + NewCnt:=NewList.Count; + AddDiff(PropertyName+'/Count',OldCnt,NewCnt); + for i:=0 to OldCnt-1 do begin + if (i>=NewCnt) then + AddDiffItem(PropertyName+'/Item'+IntToStr(i),'deleted='+OldList[i]) + else if (OldList[i]<>NewList[i]) then AddDiffItem(PropertyName+'/Item'+IntToStr(i),NewList[i]); end; end; diff --git a/ide/frames/compiler_buildmacro_options.lfm b/ide/frames/compiler_buildmacro_options.lfm index 53869967e1..05403946b7 100644 --- a/ide/frames/compiler_buildmacro_options.lfm +++ b/ide/frames/compiler_buildmacro_options.lfm @@ -120,7 +120,6 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame ParentColor = False ParentFont = False TabOrder = 0 - OnExit = CondSynEditExit Gutter.Width = 55 Gutter.MouseActions = < item diff --git a/ide/frames/compiler_buildmacro_options.pas b/ide/frames/compiler_buildmacro_options.pas index 4c8012916d..1bd46c6662 100644 --- a/ide/frames/compiler_buildmacro_options.pas +++ b/ide/frames/compiler_buildmacro_options.pas @@ -62,21 +62,18 @@ type var AllowEdit: Boolean); procedure BuildMacrosTreeViewSelectionChanged(Sender: TObject); procedure BuildMacrosTVPopupMenuPopup(Sender: TObject); - procedure CondSynEditExit(Sender: TObject); procedure DeleteBuildMacroClick(Sender: TObject); procedure NewBuildMacroClick(Sender: TObject); procedure NewValueClick(Sender: TObject); procedure DeleteValueClick(Sender: TObject); private FBuildMacros: TIDEBuildMacros; - FOptions: TBaseCompilerOptions; fVarImgID: LongInt; fValueImgID: LongInt; fDefValueImgID: LongInt; procedure SaveItemProperties; procedure SetBuildMacros(const AValue: TIDEBuildMacros); procedure RebuildTreeView; - procedure SetOptions(const AValue: TBaseCompilerOptions); function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode; procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string); function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType; @@ -88,8 +85,9 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; - property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros; - property Options: TBaseCompilerOptions read FOptions write SetOptions; + property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros; // local copy + procedure LoadFromOptions(Options: TBaseCompilerOptions); + procedure SaveToOptions(Options: TBaseCompilerOptions); end; implementation @@ -222,11 +220,6 @@ begin Add('Delete build macro ...',@DeleteBuildMacroClick); end; -procedure TCompOptBuildMacrosFrame.CondSynEditExit(Sender: TObject); -begin - Options.Conditionals:=CondSynEdit.Lines.Text; -end; - procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean); var @@ -298,7 +291,7 @@ procedure TCompOptBuildMacrosFrame.SetBuildMacros( const AValue: TIDEBuildMacros); begin if FBuildMacros=AValue then exit; - FBuildMacros:=AValue; + BuildMacros.Assign(AValue); RebuildTreeView; UpdateItemPropertyControls; end; @@ -317,15 +310,6 @@ begin BuildMacrosTreeView.EndUpdate; end; -procedure TCompOptBuildMacrosFrame.SetOptions(const AValue: TBaseCompilerOptions - ); -begin - if FOptions=AValue then exit; - FOptions:=AValue; - BuildMacros:=Options.BuildMacros as TIDEBuildMacros; - CondSynEdit.Lines.Text:=Options.Conditionals; -end; - function TCompOptBuildMacrosFrame.TreeViewAddBuildMacro( aBuildMacro: TLazBuildMacro): TTreeNode; var @@ -433,13 +417,14 @@ begin GetSelectedNode(BuildMacro,NodeType); if BuildMacro=nil then exit; BuildMacro.Description:=BuildMacroDescriptionEdit.Text; - Options.Conditionals:=CondSynEdit.Lines.Text; end; constructor TCompOptBuildMacrosFrame.Create(TheOwner: TComponent); begin inherited Create(TheOwner); + FBuildMacros:=TIDEBuildMacros.Create(nil); + MacrosGroupBox.Caption:='Build macros:'; BuildMacrosTreeView.Images := IDEImages.Images_24; fVarImgID:=IDEImages.LoadImage(24,'da_define'); @@ -454,8 +439,24 @@ end; destructor TCompOptBuildMacrosFrame.Destroy; begin + FreeAndNil(FBuildMacros); inherited Destroy; end; +procedure TCompOptBuildMacrosFrame.LoadFromOptions(Options: TBaseCompilerOptions + ); +begin + BuildMacros:=Options.BuildMacros as TIDEBuildMacros; + CondSynEdit.Lines.Text:=Options.Conditionals; +end; + +procedure TCompOptBuildMacrosFrame.SaveToOptions(Options: TBaseCompilerOptions + ); +begin + SaveItemProperties; + (Options.BuildMacros as TIDEBuildMacros).Assign(BuildMacros); + Options.Conditionals:=CondSynEdit.Lines.Text; +end; + end.