IDE: message widow: fixed showing ExitCode instead of ExitStatus of a process

git-svn-id: trunk@59899 -
This commit is contained in:
mattias 2018-12-23 16:06:52 +00:00
parent 9e8af3629d
commit 56ce57eedc
6 changed files with 45 additions and 11 deletions

View File

@ -379,6 +379,7 @@ type
TExtToolView = class(TComponent)
private
FCaption: string;
FExitCode: integer;
FExitStatus: integer;
FLines: TMessageLines;
FMinUrgency: TMessageLineUrgency;
@ -414,6 +415,7 @@ type
property Tool: TAbstractExternalTool read FTool;
property Caption: string read FCaption write FCaption;
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged; // called in main thread
property ExitCode: integer read FExitCode write FExitCode;
property ExitStatus: integer read FExitStatus write FExitStatus;
property MinUrgency: TMessageLineUrgency read FMinUrgency write FMinUrgency default DefaultETViewMinUrgency; // hide messages below this
property MessageLineClass: TMessageLineClass read FMessageLineClass;
@ -464,6 +466,7 @@ type
FData: TObject;
FEnvironmentOverrides: TStrings;
FEstimatedLoad: int64;
FExitCode: integer;
FExitStatus: integer;
FFreeData: boolean;
FGroup: TExternalToolGroup;
@ -494,7 +497,6 @@ type
const AMethod: TMethod);
protected
FErrorMessage: string;
FExitCode: integer;
FTerminated: boolean;
FHandlers: array[TExternalToolHandler] of TMethodList;
FStage: TExternalToolStage;
@ -553,6 +555,7 @@ type
procedure Terminate; virtual; abstract;
procedure WaitForExit; virtual; abstract;
property Terminated: boolean read FTerminated;
property ExitCode: integer read FExitCode write FExitCode;
property ExitStatus: integer read FExitStatus write FExitStatus;
property ErrorMessage: string read FErrorMessage write FErrorMessage; // error executing tool
property ReadStdOutBeforeErr: boolean read FReadStdOutBeforeErr write FReadStdOutBeforeErr;
@ -2458,8 +2461,10 @@ begin
finally
LeaveCriticalSection;
end;
if Tool<>nil then
if Tool<>nil then begin
ExitCode:=Tool.ExitCode;
ExitStatus:=Tool.ExitStatus;
end;
ToolExited;
if Assigned(OnChanged) then begin
RemoveAsyncOnChanged;

View File

@ -668,7 +668,7 @@ begin
inherited ToolExited;
if Tool.Terminated then begin
ToolState:=lmvtsFailed;
end else if (ExitStatus<>0) then begin
end else if (ExitStatus<>0) or (ExitCode<>0) then begin
// tool stopped with errors
ErrCount:=0;
EnterCriticalSection;
@ -700,9 +700,14 @@ begin
end;
MsgLine:=PendingLines.CreateLine(-1);
MsgLine.Urgency:=mluPanic;
MsgLine.Msg:=Format(
lisToolStoppedWithExitCodeUseContextMenuToGetMoreInfo, [IntToStr(
ExitStatus)]);
if ExitCode<>0 then
MsgLine.Msg:=Format(
lisToolStoppedWithExitCodeUseContextMenuToGetMoreInfo, [IntToStr(
ExitCode)])
else
MsgLine.Msg:=Format(
lisToolStoppedWithExitStatusUseContextMenuToGetMoreInfo, [
IntToStr(ExitStatus)]);
PendingLines.Add(MsgLine);
finally
LeaveCriticalSection;
@ -3280,8 +3285,10 @@ begin
s+='ProcessID:'+LineEnding+IntToStr(Proc.ProcessID)+LineEnding+LineEnding;
if Tool.Terminated then
s+='Terminated'+LineEnding+LineEnding
else
else begin
s+='ExitCode:'+LineEnding+IntToStr(Proc.ExitCode)+LineEnding;
s+='ExitStatus:'+LineEnding+IntToStr(Proc.ExitStatus)+LineEnding+LineEnding;
end;
end;
if Tool.ErrorMessage<>'' then
s+=lisError+Tool.ErrorMessage+LineEnding+LineEnding;

View File

@ -75,6 +75,7 @@ type
public
property Tool: TExternalTool read FTool write SetTool;
procedure Execute; override;
procedure DebuglnThreadLog(const Args: array of const);
destructor Destroy; override;
end;
@ -209,8 +210,13 @@ begin
{$ENDIF}
EnterCriticalSection;
try
if (not Terminated) and (ExitStatus<>0) and (ErrorMessage='') then
ErrorMessage:=Format(lisExitCode, [IntToStr(ExitStatus)]);
if (not Terminated) and (ErrorMessage='') then
begin
if ExitCode<>0 then
ErrorMessage:=Format(lisExitCode, [IntToStr(ExitCode)])
else if ExitStatus<>0 then
ErrorMessage:='ExitStatus '+IntToStr(ExitStatus);
end;
if FStage>=etsStopped then exit;
FStage:=etsStopped;
finally
@ -1495,7 +1501,7 @@ begin
if (fLines.Count>0)
and (Abs(int64(GetTickCount64)-LastUpdate)>UpdateTimeDiff) then begin
{$IFDEF VerboseExtToolThread}
DebuglnThreadLog(['TExternalToolThread.Execute ',Title,' ',TimeToStr(Now),' ',IntToStr(GetTickCount),' AddOutputLines ...']);
DebuglnThreadLog(['TExternalToolThread.Execute ',Title,' ',TimeToStr(Now),' ',IntToStr(GetTickCount64),' AddOutputLines ...']);
{$ENDIF}
Tool.AddOutputLines(fLines);
{$IFDEF VerboseExtToolThread}
@ -1539,6 +1545,11 @@ begin
DebuglnThreadLog(['TExternalToolThread.Execute ',Title,' reading exit status ...']);
{$ENDIF}
Tool.ExitStatus:=Tool.Process.ExitStatus;
Tool.ExitCode:=Tool.Process.ExitCode;
{$IFDEF VerboseExtToolThread}
if Tool.ExitStatus<>0 then
DebuglnThreadLog(['TExternalToolThread.Execute ',Title,' exit status=',Tool.ExitStatus,' ExitCode=',Tool.ExitCode]);
{$ENDIF}
except
Tool.ErrorMessage:=lisUnableToReadProcessExitStatus;
end;
@ -1591,6 +1602,11 @@ begin
{$ENDIF}
end;
procedure TExternalToolThread.DebuglnThreadLog(const Args: array of const);
begin
debugln(Args);
end;
destructor TExternalToolThread.Destroy;
begin
Tool:=nil;

View File

@ -92,9 +92,12 @@ begin
if Tool.Terminated then begin
ToolState:=lmvtsFailed;
debugln('Error: (lazarus) ',Caption,': terminated');
end else if (ExitCode<>0) then begin
ToolState:=lmvtsFailed;
debugln('Error: (lazarus) ',Caption,': stopped with exit code '+IntToStr(ExitCode));
end else if (ExitStatus<>0) then begin
ToolState:=lmvtsFailed;
debugln('Error: (lazarus) ',Caption,': stopped with exit code '+IntToStr(ExitStatus));
debugln('Error: (lazarus) ',Caption,': stopped with exit status '+IntToStr(ExitStatus));
end else if Tool.ErrorMessage<>'' then begin
ToolState:=lmvtsFailed;
debugln('Error: (lazarus) ',Caption,': ',Tool.ErrorMessage);

View File

@ -219,6 +219,7 @@ begin
sl.Add(' Process.Running='+dbgs(Tool.Process.Running));
sl.Add(' CmdLineParams='+AnsiQuotedStr(Tool.CmdLineParams,'"'));
sl.Add(' ErrorMessage='+AnsiQuotedStr(Tool.ErrorMessage,'"'));
sl.Add(' ExitCode='+IntToStr(Tool.ExitCode));
sl.Add(' ExitStatus='+IntToStr(Tool.ExitStatus));
sl.Add(' Terminated='+dbgs(Tool.Terminated));
sl.Add(' ReadStdOutBeforeErr='+dbgs(Tool.ReadStdOutBeforeErr));

View File

@ -619,6 +619,8 @@ resourcestring
lisShowMessageTypeID = 'Show Message Type ID';
lisToolStoppedWithExitCodeUseContextMenuToGetMoreInfo = 'tool stopped with '
+'exit code %s. Use context menu to get more information.';
lisToolStoppedWithExitStatusUseContextMenuToGetMoreInfo = 'tool stopped with '
+'ExitCode 0 and ExitStatus %s. Use context menu to get more information.';
lisErrors2 = ', Errors: %s';
lisWarnings = ', Warnings: %s';
lisHints = ', Hints: %s';