'destroy_data' in g_cclosure_new is registered as finalize notifier instread invalidate.
Submitted by Andrey Tsyvarev
Documentation states about g_cclosure_new:
Creates a new closure which invokes callback_func with user_data as the last parameter.
callback_func : the function to invoke user_data : user data to pass to callback_func destroy_data : destroy notify to be called when user_data is no longer used Returns : a new GCClosure
From this description, 'user_data' became a value of the 'data' field of the GClosure created. This value becomes unused inside closure, when g_closure_invalidate is called.
So, one may expect, that 'destroy_data' function is called in result of g_closure_invalidate (simply, is registered with g_closure_add_invalidate_notifier). But actually, this function is registered with g_closure_add_finalize_notifier, and is called only when closure is destroyed.
After the closure is invalidated, it may be a while before it is destroyed (if g_closure_invalidate is called not in the result of g_closure_unref).
Moreover, one may drop the last reference to the closure in 'destroy_data' function, and expect that this mechanism will be activated when g_closure_invalidate is called (otherwise, finalization of closure doesn't occur at all.).
So, registering 'destroy_data' as finalization notifier instead of invalidation one is incorrect from the view of documentation and may lead to unneeded usage of the system's resources and even to errors in program's logic.
Also, it is worth to note that in the g_cclosure_new_object notification function is registered as invalidate notifier(via g_object_watch_closure).