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
This commit is contained in:
Lennart Poettering 2010-01-08 20:06:21 +01:00 committed by Colin Guthrie
parent 5e2a80c7e3
commit 66dbca1e06
7 changed files with 34 additions and 34 deletions

View file

@ -37,6 +37,7 @@ struct pa_bluetooth_discovery {
PA_LLIST_HEAD(pa_dbus_pending, pending);
pa_hashmap *devices;
pa_hook hook;
pa_bool_t filter_added;
};
static void get_properties_reply(DBusPendingCall *pending, void *userdata);
@ -788,6 +789,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
pa_log_error("Failed to add filter function");
goto fail;
}
y->filter_added = TRUE;
if (pa_dbus_add_matches(
pa_dbus_connection_get(y->connection), &err,
@ -856,7 +858,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
"type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'", NULL);
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
if (y->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
pa_dbus_connection_unref(y->connection);
}