config-policy: avoid race condition in the unit tests

Clear self->pending_endpoint before sending the done signal,
because the signal will trigger a new endpoint to be added in the
unit test and this may happen before g_clear_object is called,
in which case adding the new endpoint fails
This commit is contained in:
George Kiagiadakis
2019-12-11 19:15:02 +02:00
parent 57ffc0435f
commit 57ac90b188

View File

@@ -73,8 +73,9 @@ on_endpoint_link_created (GObject *initable, GAsyncResult *res, gpointer p)
gboolean is_capture = gboolean is_capture =
wp_base_endpoint_get_direction (self->pending_endpoint) == PW_DIRECTION_INPUT; wp_base_endpoint_get_direction (self->pending_endpoint) == PW_DIRECTION_INPUT;
if (self->pending_endpoint == (is_capture ? sink_ep : src_ep)) { if (self->pending_endpoint == (is_capture ? sink_ep : src_ep)) {
g_signal_emit (self, signals[SIGNAL_DONE], 0, self->pending_endpoint, link); g_autoptr (WpBaseEndpoint) pending_endpoint =
g_clear_object (&self->pending_endpoint); g_steal_pointer (&self->pending_endpoint);
g_signal_emit (self, signals[SIGNAL_DONE], 0, pending_endpoint, link);
} }
} }
} }