Destroying an object that uses GCancellable
- From: Nader Morshed <morshed nader gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Destroying an object that uses GCancellable
- Date: Thu, 17 Jun 2010 22:15:48 -0700
Hi, I'm having some difficulties with figuring out how to properly structure an object of mine; the object
takes in a GSocketConnection and generates in/output streams and starts a read_line loop. However, when I go
to destroy the object, calling g_cancellable_cancel within either the finalize or dispose functions causes
the read cycle to incorrectly fail. This is because of an initial g_return_if_fail assertion at the beginning
of the read cycle's asynchronous callback as the object has been freed and the user_data pointer is no longer
valid.
Here's the relavent section of code for this issue, sorry if it's not too clean right now:
http://pastebin.com/Yt6RX5qQ
I saw that gfilenamecompleter.c in the gio source folder uses a separate structure containing the
GCancellable as well as the object, and I suppose one could always do manual cycle through the main loop
through checking for and dispatching events within the finalize function in order to have the read's _async
part complete, but both seem like sub-optimal solutions, so I was wondering if anyone on the list could lend
their input on this matter.
--
Nader Morshed <morshed nader gmail com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]