Hash-table valued properties
If you have a property of type G_TYPE_HASH_TABLE (types supplied through GObject introspection annotations), then the observed behavior is:
- A reference to the hash table is leaked
- References to the objects in the hash table are stolen
The code is
} else if (g_type_is_a (pspec->value_type, G_TYPE_BOXED)) {
arg.v_pointer = g_value_dup_boxed (&value);
transfer = GI_TRANSFER_EVERYTHING;
}
[...]
py_value = _pygi_argument_to_object (&arg, type_info, transfer);
and for hash tables the code in _pygi_argument_to_object never unrefs the hash table itself without regard to transfer - maybe it does for other boxed types like structures?
In addition to this, I think EVERYTHING above is also wrong - to me, the canonical way to implement a hash-valued property getter would be:
g_value_set_boxed(value, myobj->hash)
which would internally call g_hash_table_ref() for a shallow reference. This is worked with pygobject at least from 2014-2017 and, if I read the code correctly, is what GJS expects as well.
Edited by Owen Taylor