diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c index 580dc003..9687c1ef 100644 --- a/client/dbus-proxy.c +++ b/client/dbus-proxy.c @@ -171,6 +171,20 @@ static void proxy_interface_create(const char *path, proxy_interface_bind_dependencies(path); } +static void proxy_interface_destroy(void *data) +{ + struct proxy_interface *proxy = data; + + l_free(proxy->path); + + if (proxy->type->ops->destroy) + proxy->type->ops->destroy(proxy->data); + + proxy->type = NULL; + + l_free(proxy); +} + static void interfaces_added_callback(struct l_dbus_message *message, void *user_data) { @@ -252,6 +266,9 @@ static void service_appeared_callback(struct l_dbus *dbus, void *user_data) static void service_disappeared_callback(struct l_dbus *dbus, void *user_data) { + l_queue_clear(proxy_interfaces, proxy_interface_destroy); + + display_disable_cmd_prompt(); } static void dbus_disconnect_callback(void *user_data) @@ -259,10 +276,6 @@ static void dbus_disconnect_callback(void *user_data) l_main_quit(); } -static void proxy_interface_destroy(void *data) -{ -} - bool dbus_proxy_init(void) { if (dbus) diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h index df0cb45f..b5276439 100644 --- a/client/dbus-proxy.h +++ b/client/dbus-proxy.h @@ -24,6 +24,7 @@ struct proxy_interface; struct proxy_interface_type_ops { void *(*create)(void); + void (*destroy)(void *data); }; struct proxy_interface_type {