From 18526da86cd4ba16e49c35069cc770c8d3840ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 7 Apr 2023 03:24:07 +0200 Subject: 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. --- tests/gimarshallingtests.c | 12 +++++++++--- 1 file 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; -- cgit v1.2.1