Gtk/GLib timeouts and pthreads


I've come into some trouble using timeouts and threads together in a GTK+
1.2 app.

I need to perform some blocking network operations and want a graphics
spinner while the connection is being set up.

My code goes like this:

[from an early time there are one or two timeouts active]

pthread_create(..); // open a thread that will do the network stuff
                    // and pthread_exit when done, and also clear a
                    // a variable so that that main thread knows it
                    // exited
while(!thread_done) {
  update spinner
  while(gtk_events_pending()) gtk_main_iteration();
  usleep(interframe interval);


And now I should be happy, but all timeouts (created with gtk_timeout_add)
in my app (which were set up before this piece of code) stop
working (calling the callback). 

If I gtk_timeout_remove them before this piece code and add them again, it
seems that the old timeouts are not removed (I get intervals too small).

Before this piece of code were added the timeouts were working fine.
The thread spawned doesn't do _anything_ with glib/gdk/gtk.

Can anyone shed some light here ?

-- Felipe

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