Re: gdk_input_*, events, refresh, etc ( help )




Hugo Varotto <hvarotto@cs.pitt.edu> writes:

> Running GDB on the core file founds that I'm running out of stack. I
> blame it to the while(gtk_events_pending() ) and the call to
> gtk_main_iteration in my callback, so I rewrote the callback function to 
> 
> if (fgets(buffer, sizeof(buffer), errfile))
> {
>    parse_output_simul( buffer );
> }
> 
> which is a lot simpler and doesn't core anymore. I replace the
> while(fgets) cause due to the high rate of the backend, sometimes there
> were too many data in the file buffer and the application wasn't getting
> out of the callback. The problem right now is that the screen is not
> refreshed very well anymore, and the application is somewhat
> unresponsive ( I'm even having some problems with some timers that are
> periodically refreshing the graph plotting ).
> 
> Could somebody send me the magic recipe to how to make the events to be
> processed and still not running out of stack space ? The out of stack
> space only happens after a somehow long simulation ( several minutes ).
> I can give more information if needed.

Instead of gtk_input_add(), you want to use the GLib main 
loop API directly so that you can set the priority of
your input handler:

 GIOChannel *channel = g_io_channel_unix_new (fd);
 g_io_add_watch_full   (channel, G_PRIORITY_DEFAULT_IDLE, G_IO_IN,
                        io_handler, NULL, NULL);
 g_io_channel_unref (channel);

This will mean that your input handler won't get called until
all interactive events and redrawing are handled.

BTW, you don't want to mix stdio with select() - so instead
of using fgets(), you should be using read(). Otherwise, there
may be data waiting in the file buffers that GLib won't
know about.

Regards,
                                        Owen



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