Re: [gtk-list] Re: gdk_input_*, events, refresh, etc ( help )
- From: Hugo Varotto <hvarotto cs pitt edu>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: gdk_input_*, events, refresh, etc ( help )
- Date: Fri, 23 Apr 1999 12:44:34 -0400
Owen, thanks !!
This has resolved all the problems, and enabled my frontend to run for
long times, stop the simulation, restart it, again. I spent a long time
trying to figure out what was doing wrong, and sent the mail to the list
as a last resort.
If somebody is interested, I can post the relevant parts of the code in
the mailing list to avoid the same headaches to more people ( basically,
I'm forking an external program from a GTK program, capturing the output
of that program, stoping it on demand, and restarting it again, all
without loosing any interactivity in the GTK program, and without
running out of stack space ).
Owen, I read in the GTK webpage that you are writing a GTK book. It will
be very nice if you include examples like this ( so not many people will
bang their heads again and again ).
Thanks again
Hugo
--
Hugo Varotto
Computer Science Dept.
University of Pittsburgh
hvarotto@cs.pitt.edu
Owen Taylor wrote:
>
> 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
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]