Method

GObjectObjectweak_ref

Declaration [src]

void
g_object_weak_ref (
  GObject* object,
  GWeakNotify notify,
  gpointer data
)

Description [src]

Adds a weak reference callback to an object. Weak references are used for notification when an object is disposed. They are called “weak references” because they allow you to safely hold a pointer to an object without calling g_object_ref() (g_object_ref() adds a strong reference, that is, forces the object to stay alive).

Note that the weak references created by this method are not thread-safe: they cannot safely be used in one thread if the object’s last g_object_unref() might happen in another thread. Use GWeakRef if thread-safety is required.

This method is not directly available to language bindings.

Parameters

notify

Type: GWeakNotify

Callback to invoke before the object is freed.

data

Type: gpointer

Extra data to pass to notify.

The argument can be NULL.
The data is owned by the caller of the method.