From 31d636dd8503bf8997a7bc1a2c83e5cb6e4e25c4 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 20 Jan 2019 22:37:58 +0100 Subject: [PATCH] fixups after fix for #336, case of dup messages, case of onTerminated never called --- src/u_main.pas | 13 +++++++++++-- src/u_processes.pas | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/u_main.pas b/src/u_main.pas index 1df64c33..c5f230f3 100644 --- a/src/u_main.pas +++ b/src/u_main.pas @@ -3154,6 +3154,15 @@ begin dmdproc.Execute; while dmdproc.Running do 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 sysutils.DeleteFile(fname + objExt); if (dmdProc.ExitStatus = 0) then @@ -3163,8 +3172,8 @@ begin fDoc, amcEdit, amkInf); end else begin - fMsgs.message(format('error: the process (%s) has returned the status %s', - [dmdproc.Executable, prettyReturnStatus(dmdproc)]), fDoc, amcEdit, amkErr); + //fMsgs.message(format('error: the process (%s) has returned the status %s', + // [dmdproc.Executable, prettyReturnStatus(dmdproc)]), fDoc, amcEdit, amkErr); fMsgs.message(shortenPath(fDoc.fileName, 25) + ' has not been compiled', fDoc, amcEdit, amkErr); end; diff --git a/src/u_processes.pas b/src/u_processes.pas index c85e8d52..fb04248d 100644 --- a/src/u_processes.pas +++ b/src/u_processes.pas @@ -63,6 +63,8 @@ type property StdErrEx: TMemoryStream read fStderrEx; // indicates if an output buffer is read property hasRead: boolean read fHasRead; + // indicates if OnTerminated was called + property doneTerminated: boolean read fDoneTerminated; end; { @@ -232,6 +234,7 @@ var buff: Byte = 0; str: TMemoryStream; begin + stored := fStdoutEx.Position; if not Running then begin // stderr has been read in its own stream @@ -243,14 +246,13 @@ begin if consume then fStderrEx.Clear; end; - fStdoutEx.Position:=0; + fStdoutEx.Position:=stored; list.LoadFromStream(fStdoutEx); if consume then fStdoutEx.Clear; end else begin lastTerm := fStdoutEx.Position; - stored := fStdoutEx.Position; while fStdoutEx.Read(buff, 1) = 1 do if buff = 10 then lastTerm := fStdoutEx.Position; fStdoutEx.Position := stored;