conceptual error in wrapping of GSource?



Source::Source() does this:

  g_source_set_callback(
      gobject_, callback_func,
      new SourceCallbackData(this), // our persistant callback data object
      &SourceCallbackData::destroy_notify_callback);

this means that when g_source_destroy_internal() is called as a main
context is torn down, GTK will call
SourceCallbackData::destroy_notify_callback() to let us know that the
data argument (arg3) is no longer in use. not so bad ... except that
SourceCallbackData::destroy_notify_callback() will call
Source::destroy_notify_callback() in almost all cases. That does this:

   // gobject_ is already invalid at this point.
    self->gobject_ = 0;

    // No exception checking: if the dtor throws, you're out of luck anyway.
    delete self;

Great, so we still have a reference count via RefPtr<Source>, but
we've deleted ourselves.

Did I miss something about how this actually works, or is the
lifecycle mgmt model here totally wrong, and should be keyed off the
reference count of Source, and not the point at which the callback
data is no longer in use?

--p


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