dbus/glib dbus-gobject.c,1.21,1.22
Colin Walters
walters at freedesktop.org
Tue May 3 10:45:37 PDT 2005
Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv2354/glib
Modified Files:
dbus-gobject.c
Log Message:
2005-05-03 Ross Burton <ross at burtonini.com>
* glib/dbus-gobject.c (dbus_g_connection_register_g_object):
Return if we get an error during registration. Set up a
weak reference on object to unregister if object is destroyed.
(unregister_gobject): New function.
Index: dbus-gobject.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gobject.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dbus-gobject.c 27 Feb 2005 17:38:12 -0000 1.21
+++ dbus-gobject.c 3 May 2005 17:45:29 -0000 1.22
@@ -1048,6 +1048,15 @@
g_static_rw_lock_writer_unlock (&info_hash_lock);
}
+static void
+unregister_gobject (DBusGConnection *connection, GObject *dead)
+{
+ char *path;
+ path = g_object_steal_data (dead, "dbus_glib_object_path");
+ dbus_connection_unregister_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (connection), path);
+ g_free (path);
+}
+
/**
* Registers a GObject at the given path. Properties, methods, and signals
* of the object can then be accessed remotely. Methods are only available
@@ -1073,12 +1082,13 @@
if (!dbus_connection_register_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (connection),
at_path,
&gobject_dbus_vtable,
- object))
+ object)) {
g_error ("Failed to register GObject with DBusConnection");
+ return;
+ }
- /* FIXME set up memory management (so we break the
- * registration if object or connection vanishes)
- */
+ g_object_set_data (object, "dbus_glib_object_path", g_strdup (at_path));
+ g_object_weak_ref (object, (GWeakNotify)unregister_gobject, connection);
}
/** @} */ /* end of public API */
More information about the dbus-commit
mailing list