Deprecate g_binding_get_source() and get_target() in favour of dup_source() and dup_target()

The old functions are not thread-safe by design.
This commit is contained in:
Sebastian Dröge
2020-11-26 19:26:25 +02:00
parent 7367c5d367
commit 52261f0abe
3 changed files with 26 additions and 6 deletions

View File

@@ -353,6 +353,7 @@ binding_default (void)
{
BindingSource *source = g_object_new (binding_source_get_type (), NULL);
BindingTarget *target = g_object_new (binding_target_get_type (), NULL);
GObject *tmp;
GBinding *binding;
binding = g_object_bind_property (source, "foo",
@@ -360,8 +361,14 @@ binding_default (void)
G_BINDING_DEFAULT);
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_assert_true ((BindingSource *) g_binding_get_source (binding) == source);
g_assert_true ((BindingTarget *) g_binding_get_target (binding) == target);
tmp = g_binding_dup_source (binding);
g_assert_nonnull (tmp);
g_assert_true ((BindingSource *) tmp == source);
g_object_unref (tmp);
tmp = g_binding_dup_target (binding);
g_assert_nonnull (tmp);
g_assert_true ((BindingTarget *) tmp == target);
g_object_unref (tmp);
g_assert_cmpstr (g_binding_get_source_property (binding), ==, "foo");
g_assert_cmpstr (g_binding_get_target_property (binding), ==, "bar");
g_assert_cmpint (g_binding_get_flags (binding), ==, G_BINDING_DEFAULT);
@@ -388,6 +395,7 @@ binding_canonicalisation (void)
BindingSource *source = g_object_new (binding_source_get_type (), NULL);
BindingTarget *target = g_object_new (binding_target_get_type (), NULL);
GBinding *binding;
GObject *tmp;
g_test_summary ("Test that bindings set up with non-canonical property names work");
@@ -396,8 +404,14 @@ binding_canonicalisation (void)
G_BINDING_DEFAULT);
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
g_assert_true ((BindingSource *) g_binding_get_source (binding) == source);
g_assert_true ((BindingTarget *) g_binding_get_target (binding) == target);
tmp = g_binding_dup_source (binding);
g_assert_nonnull (tmp);
g_assert_true ((BindingSource *) tmp == source);
g_object_unref (tmp);
tmp = g_binding_dup_target (binding);
g_assert_nonnull (tmp);
g_assert_true ((BindingTarget *) tmp == target);
g_object_unref (tmp);
g_assert_cmpstr (g_binding_get_source_property (binding), ==, "double-value");
g_assert_cmpstr (g_binding_get_target_property (binding), ==, "double-value");
g_assert_cmpint (g_binding_get_flags (binding), ==, G_BINDING_DEFAULT);