From 66dbca1e06af0607a2d0fc6b8d14ef1ebb034f0a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Jan 2010 20:06:21 +0100 Subject: dbus: remove filter functions only if they were actually set before This fixes an assert when destructing modules that have not been fully initialized. https://bugzilla.redhat.com/show_bug.cgi?id=548525 --- src/modules/bluetooth/module-bluetooth-proximity.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/modules/bluetooth/module-bluetooth-proximity.c') diff --git a/src/modules/bluetooth/module-bluetooth-proximity.c b/src/modules/bluetooth/module-bluetooth-proximity.c index c4cfd733..3eed9cea 100644 --- a/src/modules/bluetooth/module-bluetooth-proximity.c +++ b/src/modules/bluetooth/module-bluetooth-proximity.c @@ -92,7 +92,8 @@ struct userdata { unsigned n_found; unsigned n_unknown; - pa_bool_t muted; + pa_bool_t muted:1; + pa_bool_t filter_added:1; }; static void update_volume(struct userdata *u) { @@ -358,9 +359,10 @@ static int add_matches(struct userdata *u, pa_bool_t add) { } else dbus_bus_remove_match(pa_dbus_connection_get(u->dbus_connection), filter2, &e); - if (add) + if (add) { pa_assert_se(dbus_connection_add_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u, NULL)); - else + u->filter_added = TRUE; + } else if (u->filter_added) dbus_connection_remove_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u); r = 0; @@ -393,9 +395,6 @@ int pa__init(pa_module*m) { u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); u->hci = pa_xstrdup(pa_modargs_get_value(ma, "hci", DEFAULT_HCI)); u->hci_path = pa_sprintf_malloc("/org/bluez/%s", u->hci); - u->n_found = u->n_unknown = 0; - u->muted = FALSE; - u->bondings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); if (!(u->dbus_connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &e))) { -- cgit