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

@ -87,6 +87,7 @@ struct userdata {
#ifdef HAVE_OSS_OUTPUT
pa_bool_t init_subdevs;
#endif
pa_bool_t filter_added:1;
};
#define CAPABILITY_ALSA "alsa"
@ -733,12 +734,9 @@ int pa__init(pa_module*m) {
goto fail;
}
m->userdata = u = pa_xnew(struct userdata, 1);
m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->context = NULL;
u->connection = NULL;
u->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
u->capability = NULL;
#ifdef HAVE_ALSA
u->use_tsched = TRUE;
@ -800,6 +798,7 @@ int pa__init(pa_module*m) {
pa_log_error("Failed to add filter function");
goto fail;
}
u->filter_added = TRUE;
if (pa_dbus_add_matches(
pa_dbus_connection_get(u->connection), &error,
@ -856,7 +855,8 @@ void pa__done(pa_module *m) {
"type='signal',sender='org.freedesktop.Hal',interface='org.freedesktop.Hal.Device.AccessControl',member='ACLRemoved'",
"type='signal',interface='org.pulseaudio.Server',member='DirtyGiveUpMessage'", NULL);
dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
if (u->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
pa_dbus_connection_unref(u->connection);
}