proxy: remove hooks in _destroy

Callers of _destroy should be able to reply on the fact that no
more events will be emited on the proxy whitout being required to
remove the hooks themselves.

Because of the refcount in the proxy, it can stay alive after the
_destroy and being used to emit events, like emit an error in
protocol-native.

Fixes #366
This commit is contained in:
Wim Taymans 2020-11-05 20:19:04 +01:00
parent a362889712
commit 3fe31862ef

View file

@ -231,6 +231,8 @@ static inline void remove_from_map(struct pw_proxy *proxy)
SPA_EXPORT
void pw_proxy_destroy(struct pw_proxy *proxy)
{
struct spa_hook *h;
pw_log_debug(NAME" %p: destroy id:%u removed:%u zombie:%u ref:%d", proxy,
proxy->id, proxy->removed, proxy->zombie, proxy->refcount);
@ -256,6 +258,10 @@ void pw_proxy_destroy(struct pw_proxy *proxy)
proxy->zombie = true;
pw_proxy_emit_destroy(proxy);
}
spa_list_consume(h, &proxy->listener_list.list, link)
spa_hook_remove(h);
pw_proxy_unref(proxy);
}