diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2023-04-07 03:24:07 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2023-04-17 18:51:18 +0200 |
commit | 18526da86cd4ba16e49c35069cc770c8d3840ea2 (patch) | |
tree | 2d60ecd387d20ba9258c5e97b6b36a4865adfdfa | |
parent | 0251634f16de5419ec1f6546b3df5b5b6a723ea4 (diff) | |
download | gobject-introspection-18526da86cd4ba16e49c35069cc770c8d3840ea2.tar.gz |
gimarshallingtests: Add strong references to transfer full variants
We marked GVariant arrays containing floating references as
transfer-full and this is leading bindings (i.e. gjs) to misleading
behavior (see https://gitlab.gnome.org/GNOME/gjs/-/issues/499).
This was definitely wrong, in fact a function returning a floating
reference should have been transfer none, and so in this case the actual
function transfer would have been container.
-rw-r--r-- | tests/gimarshallingtests.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 6adc978e..4c3889ea 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -1880,12 +1880,18 @@ gi_marshalling_tests_array_gvariant_full_in (GVariant **variants) g_assert (variants[2] == NULL); /* To catch different behaviors we reconstruct one variant from scratch, - * while leaving the other untouched. Both approaches are legal with full + * while taking the refernce of the other. Both approaches are legal with full * transfer in and out */ container = g_new0 (GVariant *, 3); - container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0])); + container[0] = g_variant_ref_sink ( + g_variant_new_int32 (g_variant_get_int32 (variants[0]))); g_variant_unref (variants[0]); - container[1] = variants[1]; + + /* In case the variant is floating, we want to transform it into a full + * reference, so that's fully owned by the container like if the case + * above, otherwise we just steal it since it has already a strong reference. + */ + container[1] = g_variant_take_ref (variants[1]); g_free (variants); return container; |