From 36593a3aba8dded2781a2bdd9b2ad0050dc939f2 Mon Sep 17 00:00:00 2001 From: Garrett Regier Date: Wed, 3 Jun 2015 17:13:53 -0700 Subject: [PATCH] binding: Remove GObject data usage It isn't actually doing anything, instead it is being managed without actually being used. This has the result that GBinding is now more thread-safe. https://bugzilla.gnome.org/show_bug.cgi?id=745013 --- gobject/gbinding.c | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/gobject/gbinding.c b/gobject/gbinding.c index e259f2c..d22dde1 100644 --- a/gobject/gbinding.c +++ b/gobject/gbinding.c @@ -192,40 +192,9 @@ enum }; static guint gobject_notify_signal_id; -static GQuark quark_gbinding = 0; G_DEFINE_TYPE (GBinding, g_binding, G_TYPE_OBJECT); -static inline void -add_binding_qdata (GObject *gobject, - GBinding *binding) -{ - GHashTable *bindings; - - bindings = g_object_get_qdata (gobject, quark_gbinding); - if (bindings == NULL) - { - bindings = g_hash_table_new (NULL, NULL); - - g_object_set_qdata_full (gobject, quark_gbinding, - bindings, - (GDestroyNotify) g_hash_table_unref); - } - - g_hash_table_add (bindings, binding); -} - -static inline void -remove_binding_qdata (GObject *gobject, - GBinding *binding) -{ - GHashTable *bindings; - - bindings = g_object_get_qdata (gobject, quark_gbinding); - if (binding != NULL) - g_hash_table_remove (bindings, binding); -} - /* the basic assumption is that if either the source or the target * goes away then the binding does not exist any more and it should * be reaped as well @@ -248,7 +217,6 @@ weak_unbind (gpointer user_data, g_signal_handler_disconnect (binding->source, binding->source_notify); g_object_weak_unref (binding->source, weak_unbind, user_data); - remove_binding_qdata (binding->source, binding); binding->source_notify = 0; binding->source = NULL; @@ -263,7 +231,6 @@ weak_unbind (gpointer user_data, g_signal_handler_disconnect (binding->target, binding->target_notify); g_object_weak_unref (binding->target, weak_unbind, user_data); - remove_binding_qdata (binding->target, binding); binding->target_notify = 0; binding->target = NULL; @@ -444,7 +411,6 @@ g_binding_unbind_internal (GBinding *binding, g_signal_handler_disconnect (binding->source, binding->source_notify); g_object_weak_unref (binding->source, weak_unbind, binding); - remove_binding_qdata (binding->source, binding); binding->source_notify = 0; binding->source = NULL; @@ -456,10 +422,7 @@ g_binding_unbind_internal (GBinding *binding, g_signal_handler_disconnect (binding->target, binding->target_notify); if (!source_is_target) - { - g_object_weak_unref (binding->target, weak_unbind, binding); - remove_binding_qdata (binding->target, binding); - } + g_object_weak_unref (binding->target, weak_unbind, binding); binding->target_notify = 0; binding->target = NULL; @@ -590,7 +553,6 @@ g_binding_constructed (GObject *gobject) FALSE); g_object_weak_ref (binding->source, weak_unbind, binding); - add_binding_qdata (binding->source, binding); if (binding->flags & G_BINDING_BIDIRECTIONAL) { @@ -608,10 +570,7 @@ g_binding_constructed (GObject *gobject) } if (binding->target != binding->source) - { - g_object_weak_ref (binding->target, weak_unbind, binding); - add_binding_qdata (binding->target, binding); - } + g_object_weak_ref (binding->target, weak_unbind, binding); } static void @@ -619,7 +578,6 @@ g_binding_class_init (GBindingClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - quark_gbinding = g_quark_from_static_string ("g-binding"); gobject_notify_signal_id = g_signal_lookup ("notify", G_TYPE_OBJECT); g_assert (gobject_notify_signal_id != 0); -- 2.7.4