GListModel: how to free memory?

In GTK 3, gtk_file_chooser_get_files() returns a GSList. In GTK 4, it returns a GListModel:

So in my GTK4 code, I replaced successfully GSList functions by GListModel functions. But why is there no equivalent to g_slist_free() ? How can I free a GListModel ?

The docs say:

a list model containing a GFile for each selected file and subfolder in the current folder. Free the returned list with g_object_unref().

It’s a normal GObject with reference counting, and you can use g_object_ref() and g_object_unref() for memory management.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.