object-manager: remove old global when exposing new global with same id

Sometimes, especially when running the wireplumber daemon with valgrind, a new
global with the same Id as another old global owned by a proxy wants to be
exposed before the old proxy is destroyed. If this happens, instead of returning
with an assertion error, we remove the old global and we export the new one.
This commit is contained in:
Julian Bouzas 2021-07-01 14:49:28 -04:00
parent 4275d91675
commit 2900dc1c23

View file

@ -1066,6 +1066,13 @@ expose_tmp_globals (WpCore *core, GAsyncResult *res, WpRegistry *self)
if (g->flags == 0)
continue;
/* if old global is owned by proxy, remove it */
if (self->globals->len > g->id) {
WpGlobal *old_g = g_ptr_array_index (self->globals, g->id);
if (old_g && (old_g->flags & WP_GLOBAL_FLAG_OWNED_BY_PROXY))
wp_global_rm_flag (old_g, WP_GLOBAL_FLAG_OWNED_BY_PROXY);
}
g_return_if_fail (self->globals->len <= g->id ||
g_ptr_array_index (self->globals, g->id) == NULL);