Re: GIOFunc called after a g_io_channel_shutdown
- From: Tristan Van Berkom <tvb gnome org>
- To: Renaud Malaval <Renaud Malaval palmsource com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GIOFunc called after a g_io_channel_shutdown
- Date: Tue, 16 May 2006 13:14:38 -0400
Renaud Malaval wrote:
Hello,
I use g_io_channel_unix_new() in a custom dialog to check somes io
events.
I close my gioChannel in the foo_dialog_response_cb(), just before
destroy the custom dialog.
To close the gioChannel I Does :
status = g_io_channel_shutdown(privP->gioChannelP, FALSE, &gerrorP); if
( gerrorP) {
g_error_free(gerrorP);
}
g_io_channel_unref(privP->gioChannelP);
I don't have errors (status is ok and no gerrorP) About 1 or 2 seconds
after that my GIOFunc callback is called and crash because of bad
context (user_data pointer is breaked)
I don't understood why the gioChannel is not closed.
Any idea, please ?
The GIOWatch has a reference to the channel, so unreffing the channel
will not destroy it untill the GIOWatch source has been destroyed...
calling g_io_channel_shutdown(); depending on the file type and what
events you are watching... may trigger an event on the fd (a hangup
detected ? or and EOF maybe ?)
Typicly... in very simple situations I do something like this:
========================================================
channel = channel_new (probably _unix_new with an fd);
source_id = g_io_add_watch (channel ... args);
g_io_channel_unref (channel); // pass ownership of the channel to the watch
/* ...now later... when shutting down I do: */
g_source_remove (source_id); // this will remove the event source and unreff the channel.
========================================================
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]