fix #118, IDE crash when ddemangle is absent or older than v2.072

This commit is contained in:
Basile Burg 2017-02-05 13:41:08 +01:00
parent c71b291558
commit 922dbda7fb
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 61 additions and 9 deletions

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, process, forms,
ce_processes, ce_common;
ce_processes, ce_common, ce_stringrange;
type
@ -35,21 +35,50 @@ var
demangler: TCEDDemangler;
constructor TCEDDemangler.create;
var
s: string = '.0.';
r: TStringRange;
v: integer;
begin
fList := TStringList.Create;
fOut := TStringList.Create;
fProc := TCEProcess.create(nil);
fProc.Executable:= exeFullName('ddemangle' + exeExt);
fProc.Options:= [poUsePipes];
fProc.OnTerminate:=@procTerminate;
fProc.ShowWindow:= swoHIDE;
fProc.execute;
fActive := true;
// up to version 2.071 ddemangle cannot be daemon-ized
with TProcess.Create(nil) do
try
Executable := exeFullName('dmd' + exeExt);
if Executable.fileExists then
begin
setLength(s, 128);
Parameters.Text:= '--version';
Options:= [poUsePipes];
ShowWindow:= swoHIDE;
execute;
output.Read(s[1], 128);
end;
finally
free;
end;
r := r.create(s);
v := r.popUntil('.')^.popFront^.takeUntil('.').yield.toInt;
fProc.Executable := exeFullName('ddemangle' + exeExt);
if (v >= 72) and fProc.Executable.fileExists then
begin
fProc.Options:= [poUsePipes];
fProc.OnTerminate:=@procTerminate;
fProc.ShowWindow:= swoHIDE;
fProc.execute;
fActive := true;
end
else fActive := false;
end;
destructor TCEDDemangler.destroy;
begin
fProc.Terminate(0);
if fProc.Running then
fProc.Terminate(0);
fProc.Free;
fOut.Free;
fList.Free;

View File

@ -43,10 +43,12 @@ type
Label1: TLabel;
private
procedure RefreshAllStatus;
function findCriticalyMissingTool: boolean;
protected
procedure SetVisible(Value: Boolean); override;
public
constructor create(aOwner: TComponent); override;
property hasMissingTools: boolean read findCriticalyMissingTool;
end;
implementation
@ -219,7 +221,7 @@ begin
'optional, the LDC D compiler');
itm.Parent := boxTools;
itm.ReAlign;
itm := TToolInfo.Construct(self, tikOptional, 'ddemangle',
itm := TToolInfo.Construct(self, tikFindable, 'ddemangle',
'optional, allows to demangle the symbols in the message widget');
itm.Parent := boxTools;
itm.ReAlign;
@ -249,6 +251,23 @@ begin
Realign;
end;
function TCEInfoWidget.findCriticalyMissingTool: boolean;
var
i: integer;
t: TToolInfo;
begin
result := false;
for i := 0 to boxTools.ControlCount -1 do
begin
if not (boxTools.Controls[i] is TToolInfo) then
continue;
t := TToolInfo(boxTools.Controls[i]);
t.refreshStatus;
if (t.fKind in [tikFindable, tikRunning]) and not t.present then
result := true;
end;
end;
procedure TCEInfoWidget.RefreshAllStatus;
var
i: integer;

View File

@ -1794,7 +1794,11 @@ begin
setSplitterWheelEvent;
if fFirstTimeCoedit then
begin
actFileNewRun.Execute;
if fInfoWidg.hasMissingTools then
fInfoWidg.showWidget;
end;
if fAppliOpts.autoCheckUpdates then
begin