gobject: new g_set_weak_pointer() & g_clear_weak_pointer() helpers

Weak-pointers are currently lacking g_set_object() & g_clear_object()
helpers equivalent. New functions (and macros, both are provided) are
convenient in many case, especially for the property's notify-on-set
pattern:

  if (g_set_weak_pointer (...))
    g_object_notify (...)

Inspired by Christian Hergert's original implementation for
gnome-builder.

https://bugzilla.gnome.org/show_bug.cgi?id=749527
This commit is contained in:
Martin Blanchard
2017-12-20 23:05:53 +01:00
committed by Philip Withnall
parent 62c4768423
commit 156d32cb80
3 changed files with 210 additions and 0 deletions

View File

@@ -279,6 +279,8 @@ g_object_weak_ref
g_object_weak_unref
g_object_add_weak_pointer
g_object_remove_weak_pointer
g_set_weak_pointer
g_clear_weak_pointer
GToggleNotify
g_object_add_toggle_ref
g_object_remove_toggle_ref