Re: gdk_io_* clarification




James Macnicol <jamesm@evans.ee.adfa.oz.au> writes:

> > > #ifndef WORKS
> > >     gdk_input_remove(tag);
> > >     gdk_input_add_full(fd, GDK_INPUT_READ, ioready, NULL,
> > >                        dnotify);
> > > #endif
> > >     gdk_input_remove(tag);
> > >     gdk_input_add_full(fd, GDK_INPUT_READ|GDK_INPUT_WRITE, ioready, NULL,
> > >                        dnotify);
> > 
> > Suprisingly enough, this actually works fine for me.
> >
> > But I wouldn't expect it to with two calls to 
> > gdk_input_remove() on the same tag. (that would cause
> > messed up refcounts for sure...)
> > 
> > Is that from the original, or is that a red herring?
> 
> 	It's from the original.  As I said in the last post, my
> handler reset the notifications and then starts up the next request,
> which also sets the file descriptors to get notification of whatever
> it needs, so you tend to get these things in lots of two.  I can see a
> way to work around this, but I'm pointing it out as a probable bug.

OK, I'm completely confused.

You surely aren't arguing that:

 gdk_input_remove(tag);
 gdk_input_remove(tag);

isn't a bug in your code - it's no different from 

 free(block);
 free(block);

But, as it happens, the way GLib is implemented, this
is completely safe, since the second call will silently
do nothing when it can't find tag in the list of active
sources. (At some future time, it might spit out warnings
or worse, so don't depend on that...)

So, this isn't your bug. Your test case, in fact, works
perfectly for me. In theory, it could be some Solaris/Linux
difference, but it is hard to see what, since the refcounting
at least should work the same on both platforms.

> 	If this is too difficult to fix, can I suggest that a warning
> against lots of fiddling around with gdk_input_* in handlers is
> mentioned in the tutorial/documentation.

If this bug is in GLib, then first, we need to find what needs
fixing. Then we need to fix it. The logic for this stuff was done
without a lot of care originally; it is supposed to work...

                                        Owen
 



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