core: Add ot_util_variant_take_ref for older GLib versions

This commit is contained in:
Colin Walters 2011-11-09 06:13:26 -05:00
parent 8b43c539cf
commit 9a8736203d
3 changed files with 15 additions and 1 deletions

View File

@ -358,7 +358,7 @@ ostree_parse_metadata_file (const char *path,
ret = TRUE;
*out_type = ret_type;
*out_variant = g_variant_take_ref (ret_variant);
*out_variant = ot_util_variant_take_ref (ret_variant);
ret_variant = NULL;
out:
if (ret_variant)

View File

@ -75,6 +75,18 @@ ot_util_variant_save (GFile *dest,
return ret;
}
GVariant *
ot_util_variant_take_ref (GVariant *variant)
{
#if GLIB_CHECK_VERSION(2,32,0)
return g_variant_take_ref (variant);
#else
if (g_variant_is_floating (variant))
return g_variant_ref_sink (variant);
return variant;
#endif
}
gboolean
ot_util_variant_map (GFile *src,
const GVariantType *type,

View File

@ -28,6 +28,8 @@ G_BEGIN_DECLS
GHashTable *ot_util_variant_asv_to_hash_table (GVariant *variant);
GVariant * ot_util_variant_take_ref (GVariant *variant);
gboolean ot_util_variant_save (GFile *dest,
GVariant *variant,
GCancellable *cancellable,