mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-21 00:40:20 +02:00
fixed AsyncProcess (with help of Mattias and Micha)
git-svn-id: trunk@9441 -
This commit is contained in:
parent
1c375508ba
commit
5d25e58f94
@ -27,7 +27,7 @@ unit OutputFilter;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, CompilerOptions, Project, Process,
|
||||
Classes, Math, SysUtils, Forms, Controls, CompilerOptions, Project, Process,
|
||||
IDEProcs, FileUtil, LclProc, LazConf, AsyncProcess, IDEMsgIntf;
|
||||
|
||||
type
|
||||
@ -241,7 +241,10 @@ begin
|
||||
// using non blocking TAsyncProcess
|
||||
Count:=TheAsyncProcess.NumBytesAvailable;
|
||||
if (Count=0) and AsyncProcessTerminated then break;
|
||||
Count:=TheProcess.Output.Read(Buf[1],length(Buf));
|
||||
if Count>0 then
|
||||
Count:=TheProcess.Output.Read(Buf[1],Min(Count,length(Buf)))
|
||||
else
|
||||
Sleep(1);
|
||||
end;
|
||||
if (TheAsyncProcess=nil) and (TheProcess.Output<>nil) then begin
|
||||
// using a blocking TProcess
|
||||
|
@ -108,6 +108,8 @@ begin
|
||||
FWaitPipeHandlers := lHandler^.Next;
|
||||
if lHandler^.Next <> nil then
|
||||
lHandler^.Next^.Prev := lHandler^.Prev;
|
||||
FILLCHAR(LHandler^, sizeof(TPipeEventInfo), 0);
|
||||
DebugLn(['TWin32WidgetSet.RemovePipeEventHandler', lHandler]);
|
||||
Dispose(lHandler);
|
||||
AHandler := nil;
|
||||
end;
|
||||
|
@ -347,17 +347,29 @@ procedure TWin32WidgetSet.CheckPipeEvents;
|
||||
var
|
||||
lHandler: PPipeEventInfo;
|
||||
lBytesAvail: dword;
|
||||
SomethingChanged: Boolean;
|
||||
ChangedCount:integer;
|
||||
begin
|
||||
lHandler := FWaitPipeHandlers;
|
||||
while lHandler <> nil do
|
||||
ChangedCount:=0;
|
||||
while (lHandler <> nil) and (ChangedCount<10) do
|
||||
begin
|
||||
SomethingChanged:=true;
|
||||
if Windows.PeekNamedPipe(lHandler^.Handle, nil, 0, nil, @lBytesAvail, nil) then
|
||||
begin
|
||||
if lBytesAvail <> 0 then
|
||||
lHandler^.OnEvent(lHandler^.UserData, [prDataAvailable]);
|
||||
lHandler^.OnEvent(lHandler^.UserData, [prDataAvailable])
|
||||
else
|
||||
SomethingChanged := false;
|
||||
end else
|
||||
lHandler^.OnEvent(lHandler^.UserData, [prBroken]);
|
||||
lHandler := lHandler^.Next;
|
||||
if SomethingChanged then
|
||||
lHandler := FWaitPipeHandlers
|
||||
else begin
|
||||
lHandler := lHandler^.Next;
|
||||
ChangedCount := 0;
|
||||
end;
|
||||
inc(ChangedCount);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -671,4 +683,4 @@ end;
|
||||
{$IFDEF ASSERT_IS_ON}
|
||||
{$UNDEF ASSERT_IS_ON}
|
||||
{$C-}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user