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
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

View File

@ -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;

View File

@ -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;

View File

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

View File

@ -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.