IDE: fixed save/load build macro values

git-svn-id: trunk@27148 -
This commit is contained in:
mattias 2010-08-19 13:49:03 +00:00
parent c366a17430
commit 63f09fd4cd
5 changed files with 44 additions and 38 deletions

View File

@ -67,7 +67,6 @@
any conditionals any conditionals
ToDo: ToDo:
- fix bug: opening package compiler options marks package as modified
- use conditionals to extend paths - use conditionals to extend paths
- use conditionals to extend usage paths - use conditionals to extend usage paths
- move the project target file to compiler options - move the project target file to compiler options
@ -138,7 +137,6 @@ type
procedure SaveToXMLConfig(aXMLConfig: TXMLConfig; const Path: string; procedure SaveToXMLConfig(aXMLConfig: TXMLConfig; const Path: string;
UsePathDelim: TPathDelimSwitch); UsePathDelim: TPathDelimSwitch);
procedure CreateDiff(OtherMode: TLazBuildMacro; Tool: TCompilerDiffTool); procedure CreateDiff(OtherMode: TLazBuildMacro; Tool: TCompilerDiffTool);
procedure Assign(Source: TIDEBuildMacro);
procedure IncreaseChangeStamp; procedure IncreaseChangeStamp;
property ChangeStamp: integer read FChangeStamp; property ChangeStamp: integer read FChangeStamp;
end; end;
@ -3634,7 +3632,7 @@ end;
procedure TIDEBuildMacro.SetValues(const AValue: TStrings); procedure TIDEBuildMacro.SetValues(const AValue: TStrings);
begin begin
if (FValues=AValue) or AValue.Equals(AValue) then exit; if (FValues=AValue) or FValues.Equals(AValue) then exit;
FValues.Assign(AValue); FValues.Assign(AValue);
IncreaseChangeStamp; IncreaseChangeStamp;
end; end;
@ -3708,14 +3706,6 @@ begin
Tool.AddStringsDiff('ValueDescriptions',ValueDescriptions,OtherMode.ValueDescriptions); Tool.AddStringsDiff('ValueDescriptions',ValueDescriptions,OtherMode.ValueDescriptions);
end; end;
procedure TIDEBuildMacro.Assign(Source: TIDEBuildMacro);
begin
Identifier:=Source.Identifier;
Values:=Source.Values;
Description:=Source.Description;
ValueDescriptions:=Source.ValueDescriptions;
end;
procedure TIDEBuildMacro.IncreaseChangeStamp; procedure TIDEBuildMacro.IncreaseChangeStamp;
begin begin
if FChangeStamp=High(FChangeStamp) then if FChangeStamp=High(FChangeStamp) then

View File

@ -783,7 +783,7 @@ begin
// conditionals + build macros // conditionals + build macros
{$IFDEF EnableBuildModes} {$IFDEF EnableBuildModes}
BuildMacrosFrame.Options:=Options; BuildMacrosFrame.LoadFromOptions(Options);
{$ENDIF} {$ENDIF}
// inherited tab // inherited tab
@ -1085,7 +1085,9 @@ begin
Options.CompilerMessages.Assign(TempMessages); Options.CompilerMessages.Assign(TempMessages);
// conditionals // conditionals
// these are all done via the frames {$IFDEF EnableBuildModes}
BuildMacrosFrame.SaveToOptions(Options);
{$ENDIF}
// other // other
Options.DontUseConfigFile := not chkConfigFile.Checked; Options.DontUseConfigFile := not chkConfigFile.Checked;
@ -1146,6 +1148,10 @@ begin
// check for change and mark as modified // check for change and mark as modified
if not OldCompOpts.IsEqual(Options) then begin if not OldCompOpts.IsEqual(Options) then begin
//Diff:=TStringList.Create;
//options.CreateDiff(OldCompOpts,Diff);
//debugln(Diff.Text);
//Diff.Free;
Options.Modified:=true; Options.Modified:=true;
IncreaseCompilerParseStamp; IncreaseCompilerParseStamp;
end; end;

View File

@ -133,10 +133,20 @@ procedure TCompilerDiffTool.AddStringsDiff(const PropertyName: string;
const OldList, NewList: TStrings); const OldList, NewList: TStrings);
var var
i: Integer; i: Integer;
OldCnt: Integer;
NewCnt: Integer;
begin begin
AddDiff(PropertyName+'/Count',OldList.Count,NewList.Count); OldCnt:=0;
for i:=0 to OldList.Count-1 do begin if OldList<>nil then
if (i>=NewList.Count) or (OldList[i]<>NewList[i]) 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]); AddDiffItem(PropertyName+'/Item'+IntToStr(i),NewList[i]);
end; end;
end; end;

View File

@ -120,7 +120,6 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
OnExit = CondSynEditExit
Gutter.Width = 55 Gutter.Width = 55
Gutter.MouseActions = < Gutter.MouseActions = <
item item

View File

@ -62,21 +62,18 @@ type
var AllowEdit: Boolean); var AllowEdit: Boolean);
procedure BuildMacrosTreeViewSelectionChanged(Sender: TObject); procedure BuildMacrosTreeViewSelectionChanged(Sender: TObject);
procedure BuildMacrosTVPopupMenuPopup(Sender: TObject); procedure BuildMacrosTVPopupMenuPopup(Sender: TObject);
procedure CondSynEditExit(Sender: TObject);
procedure DeleteBuildMacroClick(Sender: TObject); procedure DeleteBuildMacroClick(Sender: TObject);
procedure NewBuildMacroClick(Sender: TObject); procedure NewBuildMacroClick(Sender: TObject);
procedure NewValueClick(Sender: TObject); procedure NewValueClick(Sender: TObject);
procedure DeleteValueClick(Sender: TObject); procedure DeleteValueClick(Sender: TObject);
private private
FBuildMacros: TIDEBuildMacros; FBuildMacros: TIDEBuildMacros;
FOptions: TBaseCompilerOptions;
fVarImgID: LongInt; fVarImgID: LongInt;
fValueImgID: LongInt; fValueImgID: LongInt;
fDefValueImgID: LongInt; fDefValueImgID: LongInt;
procedure SaveItemProperties; procedure SaveItemProperties;
procedure SetBuildMacros(const AValue: TIDEBuildMacros); procedure SetBuildMacros(const AValue: TIDEBuildMacros);
procedure RebuildTreeView; procedure RebuildTreeView;
procedure SetOptions(const AValue: TBaseCompilerOptions);
function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode; function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode;
procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string); procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string);
function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType; function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType;
@ -88,8 +85,9 @@ type
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros; property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros; // local copy
property Options: TBaseCompilerOptions read FOptions write SetOptions; procedure LoadFromOptions(Options: TBaseCompilerOptions);
procedure SaveToOptions(Options: TBaseCompilerOptions);
end; end;
implementation implementation
@ -222,11 +220,6 @@ begin
Add('Delete build macro ...',@DeleteBuildMacroClick); Add('Delete build macro ...',@DeleteBuildMacroClick);
end; end;
procedure TCompOptBuildMacrosFrame.CondSynEditExit(Sender: TObject);
begin
Options.Conditionals:=CondSynEdit.Lines.Text;
end;
procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEditing(Sender: TObject; procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEditing(Sender: TObject;
Node: TTreeNode; var AllowEdit: Boolean); Node: TTreeNode; var AllowEdit: Boolean);
var var
@ -298,7 +291,7 @@ procedure TCompOptBuildMacrosFrame.SetBuildMacros(
const AValue: TIDEBuildMacros); const AValue: TIDEBuildMacros);
begin begin
if FBuildMacros=AValue then exit; if FBuildMacros=AValue then exit;
FBuildMacros:=AValue; BuildMacros.Assign(AValue);
RebuildTreeView; RebuildTreeView;
UpdateItemPropertyControls; UpdateItemPropertyControls;
end; end;
@ -317,15 +310,6 @@ begin
BuildMacrosTreeView.EndUpdate; BuildMacrosTreeView.EndUpdate;
end; 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( function TCompOptBuildMacrosFrame.TreeViewAddBuildMacro(
aBuildMacro: TLazBuildMacro): TTreeNode; aBuildMacro: TLazBuildMacro): TTreeNode;
var var
@ -433,13 +417,14 @@ begin
GetSelectedNode(BuildMacro,NodeType); GetSelectedNode(BuildMacro,NodeType);
if BuildMacro=nil then exit; if BuildMacro=nil then exit;
BuildMacro.Description:=BuildMacroDescriptionEdit.Text; BuildMacro.Description:=BuildMacroDescriptionEdit.Text;
Options.Conditionals:=CondSynEdit.Lines.Text;
end; end;
constructor TCompOptBuildMacrosFrame.Create(TheOwner: TComponent); constructor TCompOptBuildMacrosFrame.Create(TheOwner: TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
FBuildMacros:=TIDEBuildMacros.Create(nil);
MacrosGroupBox.Caption:='Build macros:'; MacrosGroupBox.Caption:='Build macros:';
BuildMacrosTreeView.Images := IDEImages.Images_24; BuildMacrosTreeView.Images := IDEImages.Images_24;
fVarImgID:=IDEImages.LoadImage(24,'da_define'); fVarImgID:=IDEImages.LoadImage(24,'da_define');
@ -454,8 +439,24 @@ end;
destructor TCompOptBuildMacrosFrame.Destroy; destructor TCompOptBuildMacrosFrame.Destroy;
begin begin
FreeAndNil(FBuildMacros);
inherited Destroy; inherited Destroy;
end; 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. end.