Re: [Vala] How are DestroyNotify func generated automatically?



Hello,

Mike Massonnet <mmassonnet    > writes:
As of bug #577048[1], the functions add_full and add_seconds_full from 
Timeout do no more take a manual DestroyNotify? notify. The bug report 
says that they are generated automatically, still I am clueless at what 
to use in place.

The line:

      Timeout.add_seconds_full (Priority.DEFAULT, 1, test);

simply expands to:

      g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1,
              _test_gsource_func, NULL, NULL);

The code is correct. The data argument is NULL, so there is nothing to
call DestroyNofify for. If there were some data, there would also be
a destroy notify.

Vala uses the data argument for the invocant of the delegate. So if
you used a non-static method test (and passed it as this.test or object.test),
the code should end up like

g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1,
        _test_gsource_func, (gpointer)self, (GDestroyNotify)g_object_unref);

(or along the lines of that -- I am not sure about the exact symbols and it
would probably include a call to g_object_ref somewhere, too)

Regards,
Jan




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