From 725eec8214b3831d01aa57e0047c25f02c0588cc Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 7 Jun 2017 08:56:35 +0200 Subject: [PATCH] battery-proxy: track bus registration ID Signed-off-by: Maciek Borzecki --- src/mconnect/battery-proxy.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index 8abcfd3..83455ba 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -23,6 +23,7 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { private Device device = null; private BatteryHandler battery_handler = null; + private uint register_id = 0; public BatteryHandlerProxy.for_device_handler(Device dev, PacketHandlerInterface iface) { @@ -42,12 +43,15 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { [DBus (visible = false)] public void bus_register(DBusConnection conn, string path) throws IOError { - conn.register_object(path, this); + if (this.register_id == 0) + this.register_id = conn.register_object(path, this); } [DBus (visible = false)] public void bus_unregister(DBusConnection conn) throws IOError { - //conn.unregister_object(this); + if (this.register_id != 0) + conn.unregister_object(this.register_id); + this.register_id = 0; } public signal void battery(uint level, bool charging);