Re: bug (?) in libbonobo that is breaking evolution



Michael Meeks <michael ximian com> writes:

> Hi Jon,
> 
> 	This chunk of code, is designed to get both ends of the X
> connection - and worse all the Gtk+ widgets idea of what X resources are
> around, and all the destruction signals synchronised on both sides of the
> synchronous CORBA connection.
> 
> 	Unfortunately it seems(?) that gtk_events_pending is always going
> to return TRUE if you have an idle handler; so I imagine we'll just block
> in there.

This doesn't make much sense to me ... g_main_pending() isn't supposed
to return TRUE unless g_main_iteration() returns TRUE. So, one shot
idle handlers or idle handlers currently in progress shouldn't cause
any harm. (idle sources will not recurse.)

The appended test, for example, works fine.

Idle handlers that aren't one-shot are essentially evil. As is iterating
the main loop out of random places in a library.... 

But getting the event loop stuck in a busy wait doing nothing
shouldn't be possible, unless you have a source, such as a closed file
descriptor, which is always returning ready.

Regards,
                                        Owen

===
#include <glib.h>

gboolean
idle_func (gpointer data)
{
  g_print ("HERE!\n");
  
  while (g_main_pending ())
    g_main_iteration (FALSE);
  
  return TRUE;
}

int main (int argc, char **argv)
{
  GMainLoop *loop = g_main_new (FALSE);

  g_idle_add (idle_func, NULL);
  g_main_run (loop);
}






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