[rygel] dbus: Add method to unregister from DBus
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] dbus: Add method to unregister from DBus
- Date: Mon, 24 Jan 2011 16:13:18 +0000 (UTC)
commit 994a1f57f5abdeb4bddd06c38ec0b8d4540067f4
Author: Jens Georg <mail jensge org>
Date: Sun Jan 23 15:32:24 2011 +0100
dbus: Add method to unregister from DBus
Register_object adds a reference to the DBusService, preventing
full cleanup on shutdown.
src/rygel/rygel-dbus-service.vala | 11 ++++++++++-
src/rygel/rygel-main.vala | 6 +++++-
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-dbus-service.vala b/src/rygel/rygel-dbus-service.vala
index 1efac35..97fca3e 100644
--- a/src/rygel/rygel-dbus-service.vala
+++ b/src/rygel/rygel-dbus-service.vala
@@ -26,6 +26,7 @@ using FreeDesktop;
[DBus (name = "org.gnome.Rygel1")]
public class Rygel.DBusService : Object, DBusInterface {
private Main main;
+ private uint connection_id;
public DBusService (Main main) throws IOError {
this.main = main;
@@ -44,10 +45,18 @@ public class Rygel.DBusService : Object, DBusInterface {
} else {
var conn = Bus.get_sync (BusType.SESSION);
- conn.register_object (DBusInterface.OBJECT_PATH, this);
+ this.connection_id = conn.register_object
+ (DBusInterface.OBJECT_PATH, this);
}
}
+ internal void unpublish () {
+ try {
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.unregister_object (this.connection_id);
+ } catch (IOError error) { }
+ }
+
public void shutdown () throws IOError {
this.main.exit (0);
}
diff --git a/src/rygel/rygel-main.vala b/src/rygel/rygel-main.vala
index f729c5b..14c70f0 100644
--- a/src/rygel/rygel-main.vala
+++ b/src/rygel/rygel-main.vala
@@ -215,7 +215,7 @@ public class Rygel.Main : Object {
private static int main (string[] args) {
Main main = null;
- DBusService service;
+ DBusService service = null;
var original_args = args;
@@ -241,6 +241,10 @@ public class Rygel.Main : Object {
int exit_code = main.run ();
+ if (service != null) {
+ service.unpublish ();
+ }
+
if (main.need_restart) {
Misc.Posix.execvp (original_args[0], original_args);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]