mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 13:02:49 +02:00
IDE: compiler options: other options: fixed dangling OnIdle, fixed thread accessing non thread safe methods
git-svn-id: trunk@45538 -
This commit is contained in:
parent
df78add6dd
commit
c0b4888159
@ -6,7 +6,7 @@ object frmAllCompilerOptions: TfrmAllCompilerOptions
|
|||||||
Caption = 'frmAllCompilerOptions'
|
Caption = 'frmAllCompilerOptions'
|
||||||
ClientHeight = 497
|
ClientHeight = 497
|
||||||
ClientWidth = 622
|
ClientWidth = 622
|
||||||
OnShow = FormShow
|
OnCreate = FormCreate
|
||||||
LCLVersion = '1.3'
|
LCLVersion = '1.3'
|
||||||
object sbAllOptions: TScrollBox
|
object sbAllOptions: TScrollBox
|
||||||
Left = 0
|
Left = 0
|
||||||
|
@ -23,7 +23,7 @@ type
|
|||||||
procedure btnResetOptionsFilterClick(Sender: TObject);
|
procedure btnResetOptionsFilterClick(Sender: TObject);
|
||||||
procedure cbShowModifiedClick(Sender: TObject);
|
procedure cbShowModifiedClick(Sender: TObject);
|
||||||
procedure edOptionsFilterChange(Sender: TObject);
|
procedure edOptionsFilterChange(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
private
|
private
|
||||||
FIdleConnected: Boolean;
|
FIdleConnected: Boolean;
|
||||||
FOptionsReader: TCompilerOptReader;
|
FOptionsReader: TCompilerOptReader;
|
||||||
@ -66,6 +66,7 @@ end;
|
|||||||
|
|
||||||
destructor TfrmAllCompilerOptions.Destroy;
|
destructor TfrmAllCompilerOptions.Destroy;
|
||||||
begin
|
begin
|
||||||
|
IdleConnected:=false;
|
||||||
FGeneratedControls.Clear;
|
FGeneratedControls.Clear;
|
||||||
FreeAndNil(FGeneratedControls);
|
FreeAndNil(FGeneratedControls);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@ -76,7 +77,7 @@ begin
|
|||||||
Result := FOptionsReader.ToCustomOptions(aStrings, cbUseComments.Checked);
|
Result := FOptionsReader.ToCustomOptions(aStrings, cbUseComments.Checked);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmAllCompilerOptions.FormShow(Sender: TObject);
|
procedure TfrmAllCompilerOptions.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Caption:=lisAllOptions;
|
Caption:=lisAllOptions;
|
||||||
edOptionsFilter.Hint := lisFilterTheAvailableOptionsList;
|
edOptionsFilter.Hint := lisFilterTheAvailableOptionsList;
|
||||||
@ -110,6 +111,8 @@ end;
|
|||||||
|
|
||||||
procedure TfrmAllCompilerOptions.SetIdleConnected(AValue: Boolean);
|
procedure TfrmAllCompilerOptions.SetIdleConnected(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
|
if csDestroying in ComponentState then
|
||||||
|
AValue:=false;
|
||||||
if FIdleConnected = AValue then exit;
|
if FIdleConnected = AValue then exit;
|
||||||
FIdleConnected := AValue;
|
FIdleConnected := AValue;
|
||||||
if FIdleConnected then
|
if FIdleConnected then
|
||||||
@ -132,9 +135,10 @@ var
|
|||||||
StartTime: TDateTime;
|
StartTime: TDateTime;
|
||||||
begin
|
begin
|
||||||
IdleConnected := False;
|
IdleConnected := False;
|
||||||
|
if FOptionsThread=nil then exit;
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
try
|
try
|
||||||
FOptionsThread.WaitFor; // Make sure the options are read.
|
FOptionsThread.EndParsing; // Make sure the options are read.
|
||||||
if FOptionsReader.ErrorMsg <> '' then
|
if FOptionsReader.ErrorMsg <> '' then
|
||||||
DebugLn(FOptionsReader.ErrorMsg)
|
DebugLn(FOptionsReader.ErrorMsg)
|
||||||
else begin
|
else begin
|
||||||
|
105
ide/compiler.pp
105
ide/compiler.pp
@ -209,6 +209,8 @@ type
|
|||||||
procedure Clear;
|
procedure Clear;
|
||||||
function UpdateTargetParam: Boolean;
|
function UpdateTargetParam: Boolean;
|
||||||
function ReadAndParseOptions: TModalResult;
|
function ReadAndParseOptions: TModalResult;
|
||||||
|
function ParseOptions(OutputI, OutputH: TStringList): TModalResult;
|
||||||
|
procedure ReadCompiler(CompPath, Params: string; out OutputI, OutputH: TStringList);
|
||||||
function FilterOptions(aFilter: string; aOnlySelected: Boolean): Boolean;
|
function FilterOptions(aFilter: string; aOnlySelected: Boolean): Boolean;
|
||||||
function FindOptionById(aId: integer): TCompilerOpt;
|
function FindOptionById(aId: integer): TCompilerOpt;
|
||||||
function FromCustomOptions(aStrings: TStrings): TModalResult;
|
function FromCustomOptions(aStrings: TStrings): TModalResult;
|
||||||
@ -228,12 +230,20 @@ type
|
|||||||
private
|
private
|
||||||
fReader: TCompilerOptReader;
|
fReader: TCompilerOptReader;
|
||||||
fReadTime: TDateTime;
|
fReadTime: TDateTime;
|
||||||
|
fCompPath: string;
|
||||||
|
fCompParams: string;
|
||||||
|
fOutputI: TStringList;
|
||||||
|
fOutputH: TStringList;
|
||||||
|
fStartedOnce: boolean;
|
||||||
function GetErrorMsg: string;
|
function GetErrorMsg: string;
|
||||||
|
procedure Clear; // (main thread)
|
||||||
protected
|
protected
|
||||||
procedure Execute; override;
|
procedure Execute; override;
|
||||||
public
|
public
|
||||||
constructor Create(aReader: TCompilerOptReader);
|
constructor Create(aReader: TCompilerOptReader);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure StartParsing; // (main thread)
|
||||||
|
procedure EndParsing; // (main thread)
|
||||||
public
|
public
|
||||||
property ReadTime: TDateTime read fReadTime;
|
property ReadTime: TDateTime read fReadTime;
|
||||||
property ErrorMsg: string read GetErrorMsg;
|
property ErrorMsg: string read GetErrorMsg;
|
||||||
@ -1166,29 +1176,43 @@ function TCompilerOptReader.ReadAndParseOptions: TModalResult;
|
|||||||
// fpc -Fr$(FPCMsgFile) -h
|
// fpc -Fr$(FPCMsgFile) -h
|
||||||
// fpc -Fr$(FPCMsgFile) -i
|
// fpc -Fr$(FPCMsgFile) -i
|
||||||
var
|
var
|
||||||
Lines: TStringList;
|
OutputI: TStringList;
|
||||||
|
OutputH: TStringList;
|
||||||
|
begin
|
||||||
|
if fCompilerExecutable = '' then
|
||||||
|
fCompilerExecutable := 'fpc'; // Let's hope "fpc" is found in PATH.
|
||||||
|
try
|
||||||
|
ReadCompiler(fCompilerExecutable, fParsedTarget, OutputI, OutputH);
|
||||||
|
Result:=ParseOptions(OutputI, OutputH);
|
||||||
|
finally
|
||||||
|
OutputI.Free;
|
||||||
|
OutputH.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompilerOptReader.ParseOptions(OutputI, OutputH: TStringList
|
||||||
|
): TModalResult;
|
||||||
begin
|
begin
|
||||||
OptionIdCounter := 0;
|
OptionIdCounter := 0;
|
||||||
fErrorMsg := '';
|
fErrorMsg := '';
|
||||||
if fCompilerExecutable = '' then
|
if OutputI = Nil then Exit(mrCancel);
|
||||||
fCompilerExecutable := 'fpc'; // Let's hope "fpc" is found in PATH.
|
Result := ParseI(OutputI);
|
||||||
// FPC with option -i
|
|
||||||
Lines:=RunTool(fCompilerExecutable, fParsedTarget + ' -i');
|
|
||||||
try
|
|
||||||
if Lines = Nil then Exit(mrCancel);
|
|
||||||
Result := ParseI(Lines);
|
|
||||||
if Result <> mrOK then Exit;
|
if Result <> mrOK then Exit;
|
||||||
finally
|
if OutputH = Nil then Exit(mrCancel);
|
||||||
Lines.Free;
|
Result := ParseH(OutputH);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCompilerOptReader.ReadCompiler(CompPath, Params: string; out
|
||||||
|
OutputI, OutputH: TStringList);
|
||||||
|
begin
|
||||||
|
OutputH:=nil;
|
||||||
|
OutputI:=nil;
|
||||||
|
if CompPath = '' then
|
||||||
|
CompPath := 'fpc'; // Let's hope "fpc" is found in PATH.
|
||||||
|
// FPC with option -i
|
||||||
|
OutputI:=RunTool(CompPath, Params + ' -i');
|
||||||
// FPC with option -h
|
// FPC with option -h
|
||||||
Lines:=RunTool(fCompilerExecutable, fParsedTarget + ' -h');
|
OutputH:=RunTool(CompPath, Params + ' -h');
|
||||||
try
|
|
||||||
if Lines = Nil then Exit(mrCancel);
|
|
||||||
Result := ParseH(Lines);
|
|
||||||
finally
|
|
||||||
Lines.Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCompilerOptReader.FilterOptions(aFilter: string; aOnlySelected: Boolean): Boolean;
|
function TCompilerOptReader.FilterOptions(aFilter: string; aOnlySelected: Boolean): Boolean;
|
||||||
@ -1364,12 +1388,15 @@ constructor TCompilerOptThread.Create(aReader: TCompilerOptReader);
|
|||||||
begin
|
begin
|
||||||
inherited Create(True);
|
inherited Create(True);
|
||||||
//FreeOnTerminate:=True;
|
//FreeOnTerminate:=True;
|
||||||
|
fStartedOnce:=false;
|
||||||
fReader:=aReader;
|
fReader:=aReader;
|
||||||
fReader.UpdateTargetParam;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCompilerOptThread.Destroy;
|
destructor TCompilerOptThread.Destroy;
|
||||||
begin
|
begin
|
||||||
|
if fStartedOnce then
|
||||||
|
WaitFor;
|
||||||
|
Clear;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1378,17 +1405,51 @@ begin
|
|||||||
Result := fReader.ErrorMsg;
|
Result := fReader.ErrorMsg;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCompilerOptThread.Clear;
|
||||||
|
begin
|
||||||
|
FreeAndNil(fOutputH);
|
||||||
|
FreeAndNil(fOutputI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCompilerOptThread.StartParsing;
|
||||||
|
begin
|
||||||
|
if fStartedOnce then
|
||||||
|
WaitFor;
|
||||||
|
fReader.CompilerExecutable:=LazarusIDE.GetFPCompilerFilename;;
|
||||||
|
fReader.UpdateTargetParam;
|
||||||
|
fCompPath:=fReader.CompilerExecutable;
|
||||||
|
fCompParams:=fReader.ParsedTarget;
|
||||||
|
Start;
|
||||||
|
fStartedOnce:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCompilerOptThread.EndParsing;
|
||||||
|
begin
|
||||||
|
if fStartedOnce then
|
||||||
|
WaitFor;
|
||||||
|
if (fOutputI<>nil) or (fOutputH<>nil) then begin
|
||||||
|
try
|
||||||
|
fReader.ParseOptions(fOutputI,fOutputH);
|
||||||
|
except
|
||||||
|
on E: Exception do
|
||||||
|
fReader.ErrorMsg := 'Error parsing compiler output: '+E.Message;
|
||||||
|
end;
|
||||||
|
Clear;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCompilerOptThread.Execute;
|
procedure TCompilerOptThread.Execute;
|
||||||
var
|
var
|
||||||
StartTime: TDateTime;
|
StartTime: TDateTime;
|
||||||
begin
|
begin
|
||||||
StartTime := Now;
|
StartTime := Now;
|
||||||
try
|
try
|
||||||
fReader.CompilerExecutable := LazarusIDE.GetFPCompilerFilename;
|
if fOutputI<>nil then exit;
|
||||||
fReader.ReadAndParseOptions;
|
if fOutputH<>nil then exit;
|
||||||
|
fReader.ReadCompiler(fCompPath,fCompParams,fOutputI,fOutputH);
|
||||||
except
|
except
|
||||||
on E: Exception do
|
on E: Exception do
|
||||||
fReader.ErrorMsg := 'Error parsing options: '+E.Message;
|
fReader.ErrorMsg := 'Error reading compiler: '+E.Message;
|
||||||
end;
|
end;
|
||||||
fReadTime := Now-StartTime;
|
fReadTime := Now-StartTime;
|
||||||
end;
|
end;
|
||||||
|
@ -161,7 +161,7 @@ begin
|
|||||||
IdleConnected := False;
|
IdleConnected := False;
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
try
|
try
|
||||||
FOptionsThread.WaitFor; // Make sure the options are read.
|
FOptionsThread.EndParsing; // Make sure the options are read.
|
||||||
// Parse and separate defines from other options.
|
// Parse and separate defines from other options.
|
||||||
FOptionsReader.FromCustomOptions(FCustomOptions);
|
FOptionsReader.FromCustomOptions(FCustomOptions);
|
||||||
// Check the found defines in the GUI.
|
// Check the found defines in the GUI.
|
||||||
|
@ -31,7 +31,7 @@ uses
|
|||||||
Classes, SysUtils, math, AVL_Tree, LazLogger, Forms, Controls, Graphics,
|
Classes, SysUtils, math, AVL_Tree, LazLogger, Forms, Controls, Graphics,
|
||||||
Dialogs, StdCtrls, LCLProc, ComCtrls, LCLType, ExtCtrls, Buttons,
|
Dialogs, StdCtrls, LCLProc, ComCtrls, LCLType, ExtCtrls, Buttons,
|
||||||
CodeToolsCfgScript, KeywordFuncLists, LazarusIDEStrConsts,
|
CodeToolsCfgScript, KeywordFuncLists, LazarusIDEStrConsts,
|
||||||
IDEOptionsIntf, CompOptsIntf, IDECommands, Project, PackageDefs,
|
IDEOptionsIntf, CompOptsIntf, IDECommands, LazIDEIntf, Project, PackageDefs,
|
||||||
CompilerOptions, Compiler, AllCompilerOptions, CustomDefines,
|
CompilerOptions, Compiler, AllCompilerOptions, CustomDefines,
|
||||||
EditorOptions, SynEdit, SynEditKeyCmds, SynCompletion, SourceSynEditor;
|
EditorOptions, SynEdit, SynEditKeyCmds, SynCompletion, SourceSynEditor;
|
||||||
|
|
||||||
@ -366,18 +366,15 @@ begin
|
|||||||
if Value then begin
|
if Value then begin
|
||||||
if Assigned(fOptionsThread) then
|
if Assigned(fOptionsThread) then
|
||||||
begin
|
begin
|
||||||
fOptionsThread.WaitFor; // Make sure the thread has finished running.
|
fOptionsThread.EndParsing; // Make sure the thread has finished running.
|
||||||
if FOptionsReader.UpdateTargetParam then begin
|
if FOptionsReader.UpdateTargetParam then begin
|
||||||
// Does not happen because UpdateTargetParam uses global macros
|
|
||||||
// which change only after closing the options window.
|
|
||||||
// This code is here for future refactoring, to react to changed target in GUI.
|
|
||||||
FOptionsReader.Clear;
|
FOptionsReader.Clear;
|
||||||
fOptionsThread.Start; // Read new options.
|
fOptionsThread.StartParsing; // Read new options.
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
fOptionsThread := TCompilerOptThread.Create(FOptionsReader);
|
fOptionsThread := TCompilerOptThread.Create(FOptionsReader);
|
||||||
fOptionsThread.Start;
|
fOptionsThread.StartParsing;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -391,6 +388,8 @@ end;
|
|||||||
|
|
||||||
procedure TCompilerOtherOptionsFrame.SetIdleConnected(AValue: Boolean);
|
procedure TCompilerOtherOptionsFrame.SetIdleConnected(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
|
if csDestroying in ComponentState then
|
||||||
|
AValue:=false;
|
||||||
if FIdleConnected=AValue then exit;
|
if FIdleConnected=AValue then exit;
|
||||||
FIdleConnected:=AValue;
|
FIdleConnected:=AValue;
|
||||||
if FIdleConnected then
|
if FIdleConnected then
|
||||||
@ -675,6 +674,7 @@ end;
|
|||||||
|
|
||||||
destructor TCompilerOtherOptionsFrame.Destroy;
|
destructor TCompilerOtherOptionsFrame.Destroy;
|
||||||
begin
|
begin
|
||||||
|
IdleConnected:=false;
|
||||||
FreeAndNil(fOptionsThread);
|
FreeAndNil(fOptionsThread);
|
||||||
FreeAndNil(FOptionsReader);
|
FreeAndNil(FOptionsReader);
|
||||||
FreeAndNil(FCompletionHistory);
|
FreeAndNil(FCompletionHistory);
|
||||||
|
Loading…
Reference in New Issue
Block a user