Re: Properly closing GIOChannels?



On Mon, 07 Feb 2005 09:37:34 +0100, Arne Skjaerholt <arnsholt online no> wrote:
[...]
/* Unref once for each call to g_io_add_watch and one final time to make
the refcount zero so the object is freed */
g_io_channel_unref ( io_channel );
g_io_channel_unref ( io_channel );
g_io_channel_unref ( io_channel );

Yes, when you g_io_channel_add_watch () there is an increment on
the ref_count of the io_channel; but this is decremented at g_source_remove
time, you are probably not the only one to have a reference on the io_channel
(glib probably needs to access it one last time in the main loop) so if its
getting prematurly destroyed, there should be a complimentary segfault  ;-)

Cheers,
                                             -Tristan



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