mirror of https://gitlab.com/basile.b/dexed.git
fix #340 - Linker messages cause coedit lock
This commit is contained in:
parent
39378d7a47
commit
aec8d9bdb0
|
@ -3095,8 +3095,7 @@ begin
|
||||||
end;
|
end;
|
||||||
deleteDups(dmdproc.Parameters);
|
deleteDups(dmdproc.Parameters);
|
||||||
dmdproc.Execute;
|
dmdproc.Execute;
|
||||||
while dmdproc.Running do
|
dmdproc.blockingWait();
|
||||||
dmdproc.checkTerminated();
|
|
||||||
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
|
||||||
|
|
|
@ -36,6 +36,7 @@ type
|
||||||
fRealOnTerminate: TNotifyEvent;
|
fRealOnTerminate: TNotifyEvent;
|
||||||
fRealOnReadData: TNotifyEvent;
|
fRealOnReadData: TNotifyEvent;
|
||||||
fOutputStack: TMemoryStream;
|
fOutputStack: TMemoryStream;
|
||||||
|
fStdError: TMemoryStream;
|
||||||
fTerminateChecker: TTimer;
|
fTerminateChecker: TTimer;
|
||||||
fDoneTerminated: boolean;
|
fDoneTerminated: boolean;
|
||||||
fHasRead: boolean;
|
fHasRead: boolean;
|
||||||
|
@ -55,10 +56,10 @@ type
|
||||||
procedure execute; override;
|
procedure execute; override;
|
||||||
// Check if process is terminated (bug 33897).
|
// Check if process is terminated (bug 33897).
|
||||||
// Not to be called in the OnTerminated handler.
|
// Not to be called in the OnTerminated handler.
|
||||||
procedure checkTerminated;
|
procedure blockingWait;
|
||||||
// Add stderr to stdout, to be called when terminated
|
// Add stderr to stdout, to be called when terminated
|
||||||
procedure appendStdErr;
|
procedure appendStdErr;
|
||||||
// reads TProcess.OUtput in OutputStack
|
// reads TProcess.Output in OutputStack
|
||||||
procedure fillOutputStack;
|
procedure fillOutputStack;
|
||||||
// fills list with the full lines contained in OutputStack
|
// fills list with the full lines contained in OutputStack
|
||||||
procedure getFullLines(list: TStrings; consume: boolean = true);
|
procedure getFullLines(list: TStrings; consume: boolean = true);
|
||||||
|
@ -170,6 +171,7 @@ constructor TCEProcess.create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
FOutputStack := TMemoryStream.Create;
|
FOutputStack := TMemoryStream.Create;
|
||||||
|
fStdError := TMemoryStream.Create;
|
||||||
FTerminateChecker := TTimer.Create(nil);
|
FTerminateChecker := TTimer.Create(nil);
|
||||||
FTerminateChecker.Interval := 100;
|
FTerminateChecker.Interval := 100;
|
||||||
fTerminateChecker.OnTimer := @checkTerminated;
|
fTerminateChecker.OnTimer := @checkTerminated;
|
||||||
|
@ -182,6 +184,7 @@ destructor TCEProcess.destroy;
|
||||||
begin
|
begin
|
||||||
FTerminateChecker.Free;
|
FTerminateChecker.Free;
|
||||||
FOutputStack.Free;
|
FOutputStack.Free;
|
||||||
|
fStdError.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -191,6 +194,7 @@ begin
|
||||||
Options := Options - [poStderrToOutPut];
|
Options := Options - [poStderrToOutPut];
|
||||||
fHasRead := false;
|
fHasRead := false;
|
||||||
fOutputStack.Clear;
|
fOutputStack.Clear;
|
||||||
|
fStdError.Clear;
|
||||||
fDoneTerminated := false;
|
fDoneTerminated := false;
|
||||||
TAsyncProcess(self).OnReadData := @internalDoOnReadData;
|
TAsyncProcess(self).OnReadData := @internalDoOnReadData;
|
||||||
TAsyncProcess(self).OnTerminate := @internalDoOnTerminate;
|
TAsyncProcess(self).OnTerminate := @internalDoOnTerminate;
|
||||||
|
@ -204,6 +208,8 @@ var
|
||||||
begin
|
begin
|
||||||
if not (poUsePipes in Options) then
|
if not (poUsePipes in Options) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
// output
|
||||||
sum := fOutputStack.Size;
|
sum := fOutputStack.Size;
|
||||||
while (Output <> nil) and (NumBytesAvailable > 0) do
|
while (Output <> nil) and (NumBytesAvailable > 0) do
|
||||||
begin
|
begin
|
||||||
|
@ -212,22 +218,33 @@ begin
|
||||||
sum += cnt;
|
sum += cnt;
|
||||||
end;
|
end;
|
||||||
fOutputStack.SetSize(sum);
|
fOutputStack.SetSize(sum);
|
||||||
|
|
||||||
|
if not fRedirectStdErr then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// error
|
||||||
|
sum := fStdError.Size;
|
||||||
|
while (Stderr <> nil) and (Stderr.NumBytesAvailable > 0) do
|
||||||
|
begin
|
||||||
|
fStdError.SetSize(sum + Stderr.NumBytesAvailable);
|
||||||
|
cnt := Stderr.Read((fStdError.Memory + sum)^, Stderr.NumBytesAvailable);
|
||||||
|
sum += cnt;
|
||||||
|
end;
|
||||||
|
fStdError.SetSize(sum);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEProcess.appendStdErr;
|
procedure TCEProcess.appendStdErr;
|
||||||
var
|
var
|
||||||
sum, cnt: Integer;
|
sum, cnt: Integer;
|
||||||
begin
|
begin
|
||||||
if not (poUsePipes in Options) then
|
if not (poUsePipes in Options) or not fRedirectStdErr then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
fillOutputStack;
|
||||||
|
fStdError.Position:=0;
|
||||||
sum := fOutputStack.Size;
|
sum := fOutputStack.Size;
|
||||||
while (Stderr <> nil) and (Stderr.NumBytesAvailable > 0) do
|
fOutputStack.SetSize(sum + fStdError.size);
|
||||||
begin
|
fStdError.Read((fOutputStack.Memory + sum)^, fStdError.Size);
|
||||||
fOutputStack.SetSize(sum + Stderr.NumBytesAvailable);
|
|
||||||
cnt := Stderr.Read((fOutputStack.Memory + sum)^, Stderr.NumBytesAvailable);
|
|
||||||
sum += cnt;
|
|
||||||
end;
|
|
||||||
fOutputStack.SetSize(sum);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEProcess.getFullLines(list: TStrings; consume: boolean = true);
|
procedure TCEProcess.getFullLines(list: TStrings; consume: boolean = true);
|
||||||
|
@ -296,8 +313,8 @@ begin
|
||||||
// note: made to fix a leak in the process used by the linter
|
// note: made to fix a leak in the process used by the linter
|
||||||
// onTerminate is sometimes determined by an internal timer
|
// onTerminate is sometimes determined by an internal timer
|
||||||
// and not the base method of TAsyncProcess (which usually unhooks)
|
// and not the base method of TAsyncProcess (which usually unhooks)
|
||||||
UnhookPipeHandle;
|
//UnhookPipeHandle;
|
||||||
UnhookProcessHandle;
|
//UnhookProcessHandle;
|
||||||
|
|
||||||
fillOutputStack;
|
fillOutputStack;
|
||||||
// note: redirection is to output stream is done by hand at the end
|
// note: redirection is to output stream is done by hand at the end
|
||||||
|
@ -317,9 +334,12 @@ begin
|
||||||
internalDoOnTerminate(self);
|
internalDoOnTerminate(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEProcess.checkTerminated;
|
procedure TCEProcess.blockingWait;
|
||||||
begin
|
begin
|
||||||
sleep(20);
|
repeat
|
||||||
|
fillOutputStack;
|
||||||
|
until
|
||||||
|
not Running;
|
||||||
checkTerminated(self);
|
checkTerminated(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue