Discussion:
Problem using TAsyncProcess.OnReadData
shoKwave
2010-07-28 17:30:31 UTC
Permalink
Hi all,

I'm trying to use TAsyncProcess and got into trouble on other widgetsets
than GTK2. The code below works fine on Ubuntu 10.04 x64 (GTK2) and
openSUSE 11.3 i386 (GTK2), but not on openSUSE 11.3 i386 (QT) or
Windows7 i386.

I played around with the options and other properties, but no message
were displayed. It seems OnReadData is never fired.

Another thing is, running "fpc" without parameter works. (Other commands
I tried "svn up", "make all" don't work)

What I'm doing wrong?


Regards
Ingo



(I know the example isn't perfect, but the message should come up, as it
does on GTK2)

uses ..., Process;

...

procedure TForm1.AsyncProcess1ReadData(Sender: TObject);
var s:String;
b:DWord;
begin
s:='';
b:=AsyncProcess1.NumBytesAvailable;
if b>0 then
begin
setlength(s, b);
AsyncProcess1.Output.Read(s[1], b);
ShowMessage(s);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
AsyncProcess1.CommandLine:='fpc -iTO';
AsyncProcess1.Options:=[poUsePipes, poStderrToOutPut];
AsyncProcess1.ShowWindow:=swoHIDE;
AsyncProcess1.Execute;
end;


--
Micha Nelissen
2010-07-31 11:25:07 UTC
Permalink
Post by shoKwave
Hi all,
I'm trying to use TAsyncProcess and got into trouble on other widgetsets
than GTK2. The code below works fine on Ubuntu 10.04 x64 (GTK2) and
openSUSE 11.3 i386 (GTK2), but not on openSUSE 11.3 i386 (QT) or
Windows7 i386.
Windows should work, I think... Qt is probably not implemented yet:

TAsyncProcess.OnReadData relies on AddPipeEventHandler working properly.
It should integrate that handle in the main event loop.

Micha


--

Loading...