On Thursday 05 April 2007 00:47, Iain * wrote:
> On 4/4/07, Chris Vine <[EMAIL PROTECTED]> wrote:
> > > > Sure. My question is, how many times (and when) do I have to call it?
> > >
> > > Once when you've finished with it
> >
> > In the context of his original question, that is not right.  His original
> > question was whether the callback returning FALSE avoids the need for an
> > explicit final call to g_io_channel_unref() to destroy the GIOChannel
> > object, assuming that before the callback returns false it only has a
> > reference count of 1.
>
> Well, yes, if you've already dropped the reference count so that its
> only depending on the watch to live then the watch will clean it up.
> But that practice would scare me as its non-deterministic as to when
> the GIOChannel will be destroyed.
>
> Common practise would be to keep a reference to the IOChannel and drop
> it once you've finished with it, which means you know better when its
> been destroyed.

I simply don't agree.  Common practice is cause the callback to return false, 
usually because end-of-file has been reached or because the remote end of a 
pipe or socket has dropped the connection.  Those conditions are only 
detectable on a read in the callback.

Less common practice is to call g_source_remove() on the return value of 
g_io_add_watch() (which is equivalent to calling g_io_channel_unref() if the 
reference count is 1).

Chris

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to