target, "bar",
G_BINDING_DEFAULT);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_assert ((BindingSource *) g_binding_get_source (binding) == source);
g_assert ((BindingTarget *) g_binding_get_target (binding) == target);
g_assert_cmpstr (g_binding_get_source_property (binding), ==, "foo");
g_object_unref (source);
g_object_unref (target);
+ g_assert (binding == NULL);
}
static void
binding = g_object_bind_property (source, "foo",
target, "bar",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_object_set (source, "foo", 42, NULL);
g_assert_cmpint (source->foo, ==, target->bar);
g_object_unref (source);
g_object_unref (target);
+ g_assert (binding == NULL);
}
static void
target, "value",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
+
g_object_get (binding,
"source", &src,
"source-property", &src_prop,
g_object_unref (target);
g_object_unref (source);
+ g_assert (binding == NULL);
}
static void
/* A -> B, B -> C */
binding_1 = g_object_bind_property (a, "foo", b, "foo", G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding_1), (gpointer *) &binding_1);
+
binding_2 = g_object_bind_property (b, "foo", c, "foo", G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding_2), (gpointer *) &binding_2);
/* verify the chain */
g_object_set (a, "foo", 42, NULL);
/* unbind A -> B and B -> C */
g_object_unref (binding_1);
+ g_assert (binding_1 == NULL);
g_object_unref (binding_2);
+ g_assert (binding_2 == NULL);
/* bind A -> C directly */
binding_2 = g_object_bind_property (a, "foo", c, "foo", G_BINDING_BIDIRECTIONAL);
"foo", 100,
"bar", 50,
NULL);
- GBinding *binding G_GNUC_UNUSED;
+ GBinding *binding;
binding = g_object_bind_property (source, "foo",
source, "bar",
G_BINDING_BIDIRECTIONAL);
+ g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_object_set (source, "foo", 10, NULL);
g_assert_cmpint (source->foo, ==, 10);
g_assert_cmpint (source->bar, ==, 30);
g_object_unref (source);
+ g_assert (binding == NULL);
}
static void
G_BINDING_DEFAULT);
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
-
g_object_set (source, "foo", 42, NULL);
g_assert_cmpint (source->foo, ==, target->bar);