Re: capturing output from running process crashes gtk2



Ratcliffe, Jeffrey (Peters) wrote:
Here is my test code. I want the dialog to be displayed and the label to be updated by the while loop. However, 
as listed, the dialog is never displayed. And of course if I make it model and add $dialog->run, then the 
while loop never gets run.

What am I doing wrong?

The problem is that you want to run the "while scanning" loop and the Gtk main loop *at the same time*, which is of course impossible. (Using dialog->run is more or less equivalent to running the gtk main loop)

You should either (A) check for pending gtk events in the while loop, or (B) you should make the code to update the label be called from the gtk main loop.

For (A) check the manual for gtk main, it contains a number of methods for handling pending gtk events. For (B) I think there are IO watch hooks in Glib which can be used to check on a file handle from gtk. Or you can connect to the idle event from gtk and do a non-blocking check of your file handle each time the idle event gets called.

-- Jaap



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]