glib.Variant uses a floating reference count system. All functions with names starting with g_variant_new_ return floating references.

Calling Variant.refSink on a glib.Variant with a floating reference will convert the floating reference into a full reference. Calling Variant.refSink on a non-floating glib.Variant results in an additional normal reference being added.

In other words, if the value is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference. If the value is not floating, then this call adds a new normal reference increasing the reference count by one.

All calls that result in a glib.Variant instance being inserted into a container will call Variant.refSink on the instance. This means that if the value was just created (and has only its floating reference) then the container will assume sole ownership of the value at that point and the caller will not need to unreference it. This makes certain common styles of programming much easier while still maintaining normal refcounting semantics in situations where values are not floating.

class Variant

Return Value

Type: Variant

the same value