From a49838f63af0e7b890f7a9c02d73ece8c4d5f333 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 4 May 2011 10:47:56 +0100 Subject: [PATCH 2/5] dbus_g_connection_register_g_object: attach ObjectExport first This means we no longer need the unnecessarily subtle "steal and put back" pattern. --- dbus/dbus-gobject.c | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index e9ea0c0..3a038ab 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -2563,12 +2563,14 @@ dbus_g_connection_register_g_object (DBusGConnection *connection, g_return_if_fail (g_variant_is_object_path (at_path)); g_return_if_fail (G_IS_OBJECT (object)); - /* After this point you must "goto put_back" to give this back to - * the object. */ - oe = g_object_steal_data (object, "dbus_glib_object_registrations"); + oe = g_object_get_data (object, "dbus_glib_object_registrations"); if (oe == NULL) - oe = object_export_new (); + { + oe = object_export_new (); + g_object_set_data_full (object, "dbus_glib_object_registrations", oe, + (GDestroyNotify) object_export_free); + } for (iter = oe->registrations; iter; iter = iter->next) { @@ -2576,7 +2578,7 @@ dbus_g_connection_register_g_object (DBusGConnection *connection, /* Silently ignore duplicate registrations */ if (strcmp (o->object_path, at_path) == 0 && o->connection == connection) - goto put_back; + return; } is_first_registration = (oe->registrations == NULL); @@ -2592,7 +2594,7 @@ dbus_g_connection_register_g_object (DBusGConnection *connection, { g_warning ("No introspection data registered for object class \"%s\"", g_type_name (G_TYPE_FROM_INSTANCE (object))); - goto put_back; + return; } } else @@ -2608,7 +2610,7 @@ dbus_g_connection_register_g_object (DBusGConnection *connection, g_error ("Failed to register GObject with DBusConnection"); object_registration_free (o); g_list_free (info_list); - goto put_back; + return; } if (is_first_registration) @@ -2622,10 +2624,6 @@ dbus_g_connection_register_g_object (DBusGConnection *connection, } oe->registrations = g_slist_append (oe->registrations, o); - -put_back: - g_object_set_data_full (object, "dbus_glib_object_registrations", oe, - (GDestroyNotify) object_export_free); } /** -- 1.7.4.4