mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Fix g_binding_unbind() when the source and target are the same
It tried to remove a weak ref, but it is only taken if the source and target object are different. https://bugzilla.gnome.org/show_bug.cgi?id=749352
This commit is contained in:
@@ -438,6 +438,8 @@ static inline void
|
||||
g_binding_unbind_internal (GBinding *binding,
|
||||
gboolean unref_binding)
|
||||
{
|
||||
gboolean source_is_target = binding->source == binding->target;
|
||||
|
||||
/* dispose of the transformation data */
|
||||
if (binding->notify != NULL)
|
||||
{
|
||||
@@ -464,8 +466,11 @@ g_binding_unbind_internal (GBinding *binding,
|
||||
if (binding->target_notify != 0)
|
||||
g_signal_handler_disconnect (binding->target, binding->target_notify);
|
||||
|
||||
g_object_weak_unref (binding->target, weak_unbind, binding);
|
||||
remove_binding_qdata (binding->target, binding);
|
||||
if (!source_is_target)
|
||||
{
|
||||
g_object_weak_unref (binding->target, weak_unbind, binding);
|
||||
remove_binding_qdata (binding->target, binding);
|
||||
}
|
||||
|
||||
binding->target_notify = 0;
|
||||
binding->target = NULL;
|
||||
|
@@ -610,6 +610,19 @@ binding_unbind (void)
|
||||
|
||||
g_object_unref (source);
|
||||
g_object_unref (target);
|
||||
|
||||
|
||||
/* g_binding_unbind() has a special case for this */
|
||||
source = g_object_new (binding_source_get_type (), NULL);
|
||||
binding = g_object_bind_property (source, "foo",
|
||||
source, "bar",
|
||||
G_BINDING_DEFAULT);
|
||||
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
|
||||
|
||||
g_binding_unbind (binding);
|
||||
g_assert (binding == NULL);
|
||||
|
||||
g_object_unref (source);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user