Unclear how to handle GPtrArray
The GPtrArray API has grown from g_ptr_array_new
to g_ptr_array_new_with_free_func
(in fact it happened 10 years ago) and it seems that all the bindings don't handle this the same way.
Let's take an example:
\**
* foo_bar_get_icons:
*
* Returns: (transfer full) (element-type GThemedIcon): a #GPtrArray of #GThemedIcons
*/
GPtrArray *
foo_bar_get_icons (void)
{
GPtrArray *array = g_ptr_array_new_with_free_func (g_object_unref);
GThemedIcon *icon = g_themed_icon_new ("application-xml");
g_ptr_array_add (array, icon);
return array;
}
Some claim that (transfer full)
is wrong because GPtrArray is owning the element but in fact, we need (transfer full)
because if we add a GIcon afterwards, we need to increase its reference count.
A (transfer container)
would in fact be something like this:
\**
* foo_bar_get_apps:
*
* Returns: (transfer container) (element-type GApplication): a #GPtrArray of #GApplication
*/
GPtrArray *
foo_bar_get_icons (void)
{
GPtrArray *array = g_ptr_array_new ();
GApplication *app = g_application_get_default ();
g_ptr_array_add (array, app);
return array;
}
Can all bindings agree on this or is there something that I'm missing?