mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
Add g_binding_dup_target() and g_binding_dup_source()
These new getters prevent the source/target from simply disappearing if they're finalized from another thread in the meantime.
This commit is contained in:
parent
51ee5cf1c2
commit
c8c829fa42
@ -978,8 +978,10 @@ g_io_condition_get_type
|
|||||||
GBinding
|
GBinding
|
||||||
GBindingFlags
|
GBindingFlags
|
||||||
g_binding_get_source
|
g_binding_get_source
|
||||||
|
g_binding_dup_source
|
||||||
g_binding_get_source_property
|
g_binding_get_source_property
|
||||||
g_binding_get_target
|
g_binding_get_target
|
||||||
|
g_binding_dup_target
|
||||||
g_binding_get_target_property
|
g_binding_get_target_property
|
||||||
g_binding_get_flags
|
g_binding_get_flags
|
||||||
g_binding_unbind
|
g_binding_unbind
|
||||||
|
@ -793,6 +793,10 @@ g_binding_get_flags (GBinding *binding)
|
|||||||
* strong reference to the source. If the source is destroyed before the
|
* strong reference to the source. If the source is destroyed before the
|
||||||
* binding then this function will return %NULL.
|
* binding then this function will return %NULL.
|
||||||
*
|
*
|
||||||
|
* Use g_binding_dup_source() if the source or binding are used from different
|
||||||
|
* threads as otherwise the pointer returned from this function might become
|
||||||
|
* invalid if the source is finalized from another thread in the meantime.
|
||||||
|
*
|
||||||
* Returns: (transfer none) (nullable): the source #GObject, or %NULL if the
|
* Returns: (transfer none) (nullable): the source #GObject, or %NULL if the
|
||||||
* source does not exist any more.
|
* source does not exist any more.
|
||||||
*
|
*
|
||||||
@ -814,6 +818,29 @@ g_binding_get_source (GBinding *binding)
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_binding_dup_source:
|
||||||
|
* @binding: a #GBinding
|
||||||
|
*
|
||||||
|
* Retrieves the #GObject instance used as the source of the binding.
|
||||||
|
*
|
||||||
|
* A #GBinding can outlive the source #GObject as the binding does not hold a
|
||||||
|
* strong reference to the source. If the source is destroyed before the
|
||||||
|
* binding then this function will return %NULL.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (nullable): the source #GObject, or %NULL if the
|
||||||
|
* source does not exist any more.
|
||||||
|
*
|
||||||
|
* Since: 2.68
|
||||||
|
*/
|
||||||
|
GObject *
|
||||||
|
g_binding_dup_source (GBinding *binding)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_BINDING (binding), NULL);
|
||||||
|
|
||||||
|
return g_weak_ref_get (&binding->source);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_binding_get_target:
|
* g_binding_get_target:
|
||||||
* @binding: a #GBinding
|
* @binding: a #GBinding
|
||||||
@ -824,6 +851,10 @@ g_binding_get_source (GBinding *binding)
|
|||||||
* strong reference to the target. If the target is destroyed before the
|
* strong reference to the target. If the target is destroyed before the
|
||||||
* binding then this function will return %NULL.
|
* binding then this function will return %NULL.
|
||||||
*
|
*
|
||||||
|
* Use g_binding_dup_target() if the target or binding are used from different
|
||||||
|
* threads as otherwise the pointer returned from this function might become
|
||||||
|
* invalid if the target is finalized from another thread in the meantime.
|
||||||
|
*
|
||||||
* Returns: (transfer none) (nullable): the target #GObject, or %NULL if the
|
* Returns: (transfer none) (nullable): the target #GObject, or %NULL if the
|
||||||
* target does not exist any more.
|
* target does not exist any more.
|
||||||
*
|
*
|
||||||
@ -845,6 +876,29 @@ g_binding_get_target (GBinding *binding)
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_binding_dup_target:
|
||||||
|
* @binding: a #GBinding
|
||||||
|
*
|
||||||
|
* Retrieves the #GObject instance used as the target of the binding.
|
||||||
|
*
|
||||||
|
* A #GBinding can outlive the target #GObject as the binding does not hold a
|
||||||
|
* strong reference to the target. If the target is destroyed before the
|
||||||
|
* binding then this function will return %NULL.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (nullable): the target #GObject, or %NULL if the
|
||||||
|
* target does not exist any more.
|
||||||
|
*
|
||||||
|
* Since: 2.68
|
||||||
|
*/
|
||||||
|
GObject *
|
||||||
|
g_binding_dup_target (GBinding *binding)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_BINDING (binding), NULL);
|
||||||
|
|
||||||
|
return g_weak_ref_get (&binding->target);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_binding_get_source_property:
|
* g_binding_get_source_property:
|
||||||
* @binding: a #GBinding
|
* @binding: a #GBinding
|
||||||
|
@ -110,8 +110,12 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
GBindingFlags g_binding_get_flags (GBinding *binding);
|
GBindingFlags g_binding_get_flags (GBinding *binding);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
GObject * g_binding_get_source (GBinding *binding);
|
GObject * g_binding_get_source (GBinding *binding);
|
||||||
|
GLIB_AVAILABLE_IN_2_68
|
||||||
|
GObject * g_binding_dup_source (GBinding *binding);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
GObject * g_binding_get_target (GBinding *binding);
|
GObject * g_binding_get_target (GBinding *binding);
|
||||||
|
GLIB_AVAILABLE_IN_2_68
|
||||||
|
GObject * g_binding_dup_target (GBinding *binding);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
const gchar * g_binding_get_source_property (GBinding *binding);
|
const gchar * g_binding_get_source_property (GBinding *binding);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user