mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-17 21:58:08 +02:00
object-manager: guard self in the idle callback using g_cclosure_new_object
The idle callback may be called after the object manager has been destroyed, or the object manager may be destroyed while emitting one of the signals from the idle callback, so it needs to be ref'ed while the callback is running. g_cclosure_new_object ensures that in both cases the code behaves correctly.
This commit is contained in:
parent
2bc999594c
commit
3db3229359
1 changed files with 3 additions and 2 deletions
|
|
@ -687,8 +687,9 @@ wp_object_manager_maybe_objects_changed (WpObjectManager * self)
|
|||
if (!self->idle_source) {
|
||||
g_autoptr (WpCore) core = g_weak_ref_get (&self->core);
|
||||
if (core) {
|
||||
wp_core_idle_add (core, &self->idle_source,
|
||||
(GSourceFunc) idle_emit_objects_changed, self, NULL);
|
||||
wp_core_idle_add_closure (core, &self->idle_source,
|
||||
g_cclosure_new_object (
|
||||
G_CALLBACK (idle_emit_objects_changed), G_OBJECT (self)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue