Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • gobject-introspection gobject-introspection
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 244
    • Issues 244
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 42
    • Merge requests 42
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gobject-introspectiongobject-introspection
  • Issues
  • #305
Closed
Open
Issue created Aug 16, 2019 by Corentin Noël@tintouDeveloper

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?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking