On Fri, Mar 27, 2009 at 14:01, Kouhei S. [email protected] wrote:
Yes. But please use G_CHILD_* with an instance not
mGLib. It’s enough that a callback block is associated with
just an instance. Lifetimes of a callback block and an
instance are same.
Yes, that was my initial thought as well. However, doing that will
complicate the code quite a bit. At the moment I simply pass the
block as the user_data to the async functions. If I associate it with
self I’ll have to pass in an allocated struct (or similar) containing
both self and the block, right?
Or can I do something like the following?
read_async_callback(GObject *source, GAsyncResult *result, gpointer
VALUE block = (VALUE)data;
rb_funcall(block, g_id_call, â€¦);
read_async(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, “…&”, …, &block);
g_file_read_async(_SELF(self), …, read_async_callback, &block);
That is, will self and GOBJ2RVAL(source) be the same VALUE? If I
understand GOBJ2RVAL correctly they won’t. Is there a way of getting
“self” in read_async_callback?
(I know that _SELF(self) and source are the same.)