Method

GObjectWeakRefget

Declaration

GObject*
g_weak_ref_get (
  GWeakRef* weak_ref
)

Description

If weak_ref is not empty, atomically acquire a strong reference to the object it points to, and return that reference.

This function is needed because of the potential race between taking the pointer value and g_object_ref() on it, if the object was losing its last reference at the same time in a different thread.

The caller should release the resulting reference in the usual way, by using g_object_unref().

Available since:2.32

Return value

Returns: GObject
 

The object pointed to by weak_ref, or NULL if it was empty.

 The caller of the method takes ownership of the data, and is responsible for freeing it.