fixups after fix for #336, case of dup messages, case of onTerminated never called

This commit is contained in:
Basile Burg 2019-01-20 22:37:58 +01:00
parent 1d5460f575
commit 31d636dd85
2 changed files with 15 additions and 4 deletions

View File

@ -3154,6 +3154,15 @@ begin
dmdproc.Execute; dmdproc.Execute;
while dmdproc.Running do while dmdproc.Running do
application.ProcessMessages; application.ProcessMessages;
// The timer in TDexedProcess still does not fix
// the "onTerminated never called bug"
if not dmdproc.doneTerminated then
begin
dmdProc.fillOutputStack;
asyncprocTerminate(dmdproc);
end;
if not asObj then if not asObj then
sysutils.DeleteFile(fname + objExt); sysutils.DeleteFile(fname + objExt);
if (dmdProc.ExitStatus = 0) then if (dmdProc.ExitStatus = 0) then
@ -3163,8 +3172,8 @@ begin
fDoc, amcEdit, amkInf); fDoc, amcEdit, amkInf);
end end
else begin else begin
fMsgs.message(format('error: the process (%s) has returned the status %s', //fMsgs.message(format('error: the process (%s) has returned the status %s',
[dmdproc.Executable, prettyReturnStatus(dmdproc)]), fDoc, amcEdit, amkErr); // [dmdproc.Executable, prettyReturnStatus(dmdproc)]), fDoc, amcEdit, amkErr);
fMsgs.message(shortenPath(fDoc.fileName, 25) + ' has not been compiled', fMsgs.message(shortenPath(fDoc.fileName, 25) + ' has not been compiled',
fDoc, amcEdit, amkErr); fDoc, amcEdit, amkErr);
end; end;

View File

@ -63,6 +63,8 @@ type
property StdErrEx: TMemoryStream read fStderrEx; property StdErrEx: TMemoryStream read fStderrEx;
// indicates if an output buffer is read // indicates if an output buffer is read
property hasRead: boolean read fHasRead; property hasRead: boolean read fHasRead;
// indicates if OnTerminated was called
property doneTerminated: boolean read fDoneTerminated;
end; end;
{ {
@ -232,6 +234,7 @@ var
buff: Byte = 0; buff: Byte = 0;
str: TMemoryStream; str: TMemoryStream;
begin begin
stored := fStdoutEx.Position;
if not Running then if not Running then
begin begin
// stderr has been read in its own stream // stderr has been read in its own stream
@ -243,14 +246,13 @@ begin
if consume then if consume then
fStderrEx.Clear; fStderrEx.Clear;
end; end;
fStdoutEx.Position:=0; fStdoutEx.Position:=stored;
list.LoadFromStream(fStdoutEx); list.LoadFromStream(fStdoutEx);
if consume then if consume then
fStdoutEx.Clear; fStdoutEx.Clear;
end else end else
begin begin
lastTerm := fStdoutEx.Position; lastTerm := fStdoutEx.Position;
stored := fStdoutEx.Position;
while fStdoutEx.Read(buff, 1) = 1 do while fStdoutEx.Read(buff, 1) = 1 do
if buff = 10 then lastTerm := fStdoutEx.Position; if buff = 10 then lastTerm := fStdoutEx.Position;
fStdoutEx.Position := stored; fStdoutEx.Position := stored;