IdeIntf: Improve timestamp updates of TLazCompilationToolOptions + inherited classes. Issue #34283.

git-svn-id: trunk@59268 -
This commit is contained in:
juha 2018-10-07 20:01:41 +00:00
parent a6008a5186
commit 6ab3884744
3 changed files with 29 additions and 52 deletions

View File

@ -18,7 +18,7 @@ interface
uses
Classes, SysUtils,
// LazUtils
LazMethodList, LazFileCache,
LazMethodList,
// IdeIntf
IDEOptionsIntf;
@ -116,31 +116,30 @@ const
crAll = [crCompile, crBuild, crRun];
type
TLazCompilerOptions = class;
{ TLazCompilationToolOptions }
TLazCompilationToolOptions = class
private
FOwner: TObject;
FChangeStamp: int64;
FOwner: TLazCompilerOptions;
FCommand: string;
FOnChanged: TNotifyEvent;
procedure SetCommand(AValue: string);
protected
FCompileReasons: TCompileReasons;
procedure SetCommand(AValue: string); virtual;
procedure SetCompileReasons(const {%H-}AValue: TCompileReasons); virtual;
public
constructor Create(TheOwner: TObject); virtual;
constructor Create(TheOwner: TLazCompilerOptions); virtual;
procedure Clear; virtual;
procedure Assign(Src: TLazCompilationToolOptions); virtual;
procedure IncreaseChangeStamp;
public
property Owner: TObject read FOwner;
property ChangeStamp: int64 read FChangeStamp;
property Owner: TLazCompilerOptions read FOwner;
property Command: string read FCommand write SetCommand;
property CompileReasons: TCompileReasons read FCompileReasons write SetCompileReasons;
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
end;
TLazCompilationToolClass = class of TLazCompilationToolOptions;
{ TLazCompilerOptions }
TLazCompilerOptions = class(TAbstractIDEOptions)
@ -209,17 +208,13 @@ type
FChangeStamp: int64;
FSavedChangeStamp: int64;
fOnChanged: TMethodList;
// Paths:
// conditionals / build modes
FConditionals: string;
fBuildMacros: TLazBuildMacros;
// Parsing:
// assembler style
fAssemblerStyle: Integer;
// syntax options
FSyntaxMode: string;
fCStyleOp: Boolean;
@ -230,7 +225,6 @@ type
fCMacros: Boolean;
fInitConst: Boolean;
fStaticKeyword: Boolean;
// Code generation:
fSmartLinkUnit: Boolean;
fRelocatableUnit: Boolean;
@ -249,7 +243,6 @@ type
fVarsInReg: Boolean;
fUncertainOpt: Boolean;
FSmallerCode: boolean;
// Linking:
fGenDebugInfo: Boolean;
FDebugInfoType: TCompilerDbgSymbolType;
@ -268,7 +261,6 @@ type
fTargetFileExt: string;
fTargetFilename: string;
FTargetFilenameAppplyConventions: boolean;
// Messages:
fShowWarn: Boolean;
fShowNotes: Boolean;
@ -287,11 +279,9 @@ type
fStopAfterErrCount: integer;
// Turn specific types of compiler messages on or off
fMessageFlags: TAbstractCompilerMsgIDFlags;
// Other tools:
fExecuteBefore: TLazCompilationToolOptions;
fExecuteAfter: TLazCompilationToolOptions;
// Other:
fDontUseConfigFile: Boolean;
fCustomConfigFile: Boolean;
@ -477,7 +467,7 @@ implementation
{ TLazCompilationToolOptions }
constructor TLazCompilationToolOptions.Create(TheOwner: TObject);
constructor TLazCompilationToolOptions.Create(TheOwner: TLazCompilerOptions);
begin
FOwner:=TheOwner;
FCompileReasons:=crAll; // This default can be used in some comparisons.
@ -495,18 +485,11 @@ begin
FCompileReasons := Src.CompileReasons;
end;
procedure TLazCompilationToolOptions.IncreaseChangeStamp;
begin
LUIncreaseChangeStamp64(FChangeStamp);
if Assigned(OnChanged) then
OnChanged(Self);
end;
procedure TLazCompilationToolOptions.SetCommand(AValue: string);
begin
if FCommand=AValue then exit;
FCommand:=AValue;
IncreaseChangeStamp;
FOwner.IncreaseChangeStamp;
end;
procedure TLazCompilationToolOptions.SetCompileReasons(const AValue: TCompileReasons);
@ -927,7 +910,7 @@ end;
function TLazCompilerOptions.GetModified: boolean;
begin
Result:=(FSavedChangeStamp=InvalidChangeStamp)
or (FSavedChangeStamp<>FChangeStamp);
or (FSavedChangeStamp<>FChangeStamp);
end;
constructor TLazCompilerOptions.Create(const TheOwner: TObject);

View File

@ -342,9 +342,10 @@ type
procedure SetHasParser(aParserName: string; const AValue: boolean);
procedure SetParsers(const AValue: TStrings);
protected
procedure SetCommand(AValue: string); override;
procedure SubstituteMacros(var s: string); virtual;
public
constructor Create(TheOwner: TObject); override;
constructor Create(TheOwner: TLazCompilerOptions); override;
destructor Destroy; override;
procedure Clear; override;
function CreateDiff(CompOpts: TCompilationToolOptions;
@ -362,7 +363,6 @@ type
property Parsers: TStrings read FParsers write SetParsers;
property HasParser[aParserName: string]: boolean read GetHasParser write SetHasParser;
end;
TCompilationToolClass = class of TCompilationToolOptions;
TCompilerMsgIdFlag = record
MsgId: integer;
@ -426,7 +426,6 @@ type
FCreateMakefileOnBuild: boolean;
function GetExecuteAfter: TCompilationToolOptions;
function GetExecuteBefore: TCompilationToolOptions;
procedure OnItemChanged(Sender: TObject);
procedure SetCreateMakefileOnBuild(AValue: boolean);
protected
function GetCompilerPath: String; override;
@ -465,8 +464,7 @@ type
procedure SetDefaultMakeOptionsFlags(const AValue: TCompilerCmdLineOptions);
public
constructor Create(const AOwner: TObject); override;
constructor Create(const AOwner: TObject;
const AToolClass: TCompilationToolClass);
constructor Create(const AOwner: TObject; const AToolClass: TLazCompilationToolClass);
destructor Destroy; override;
procedure Clear; virtual;
class function GetInstance: TAbstractIDEOptions; override;
@ -1103,15 +1101,13 @@ end;
TBaseCompilerOptions Constructor
------------------------------------------------------------------------------}
constructor TBaseCompilerOptions.Create(const AOwner: TObject;
const AToolClass: TCompilationToolClass);
const AToolClass: TLazCompilationToolClass);
begin
inherited Create(AOwner);
FParsedOpts := TParsedCompilerOptions.Create(Self);
FOtherDefines := TStringList.Create;
FExecuteBefore := AToolClass.Create(Self);
FExecuteBefore.OnChanged := @OnItemChanged;
FExecuteAfter := AToolClass.Create(Self);
fExecuteAfter.OnChanged := @OnItemChanged;
fBuildMacros := TIDEBuildMacros.Create(Self);
fMessageFlags:=TCompilerMsgIDFlags.Create;
Clear;
@ -1305,14 +1301,6 @@ begin
Result:=(inherited GetModified) or MessageFlags.Modified;
end;
procedure TBaseCompilerOptions.OnItemChanged(Sender: TObject);
begin
{$IFDEF VerboseIDEModified}
debugln(['TBaseCompilerOptions.OnItemChanged ',DbgSName(Sender)]);
{$ENDIF}
IncreaseChangeStamp;
end;
procedure TBaseCompilerOptions.SetCreateMakefileOnBuild(AValue: boolean);
begin
if FCreateMakefileOnBuild=AValue then Exit;
@ -4235,7 +4223,7 @@ begin
if not AValue then exit;
FParsers.Add(aParserName);
end;
IncreaseChangeStamp;
Owner.IncreaseChangeStamp;
end;
procedure TCompilationToolOptions.SetParsers(const AValue: TStrings);
@ -4245,7 +4233,13 @@ begin
debugln(['TCompilationToolOptions.SetParsers ',AValue.Text]);
{$ENDIF}
FParsers.Assign(AValue);
IncreaseChangeStamp;
Owner.IncreaseChangeStamp;
end;
procedure TCompilationToolOptions.SetCommand(AValue: string);
begin
inherited SetCommand(AValue);
Inc(FParsedCommandStamp);
end;
procedure TCompilationToolOptions.SubstituteMacros(var s: string);
@ -4253,7 +4247,7 @@ begin
IDEMacros.SubstituteMacros(s);
end;
constructor TCompilationToolOptions.Create(TheOwner: TObject);
constructor TCompilationToolOptions.Create(TheOwner: TLazCompilerOptions);
begin
inherited Create(TheOwner);
FParsers:=TStringList.Create;

View File

@ -490,7 +490,7 @@ type
procedure SetCompileReasons(const AValue: TCompileReasons); override;
procedure SubstituteMacros(var s: string); override;
public
constructor Create(TheOwner: TObject); override;
constructor Create(TheOwner: TLazCompilerOptions); override;
function CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool): boolean; override;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
@ -5983,7 +5983,7 @@ end;
{ TProjectCompilationToolOptions }
constructor TProjectCompilationToolOptions.Create(TheOwner: TObject);
constructor TProjectCompilationToolOptions.Create(TheOwner: TLazCompilerOptions);
begin
inherited Create(TheOwner);
FDefaultCompileReasons:=crAll;
@ -6029,14 +6029,14 @@ procedure TProjectCompilationToolOptions.SetCompileReasons(const AValue: TCompil
begin
if FCompileReasons=AValue then exit;
FCompileReasons:=AValue;
IncreaseChangeStamp;
Owner.IncreaseChangeStamp;
end;
procedure TProjectCompilationToolOptions.SetDefaultCompileReasons(const AValue: TCompileReasons);
begin
if FDefaultCompileReasons=AValue then exit;
FDefaultCompileReasons:=AValue;
IncreaseChangeStamp;
Owner.IncreaseChangeStamp;
end;
procedure TProjectCompilationToolOptions.SubstituteMacros(var s: string);