From 6fe5baa0cd9254d45a7cd13fa21aeb4df39e5274 Mon Sep 17 00:00:00 2001 From: Fabiano FidĂȘncio Date: Wed, 17 Feb 2016 21:41:58 +0100 Subject: usb-acl-helper: bring the cancellable back Don't try to use the cancellable from the GTask. There are several cases where we need to take care of disconnecting the cancellable and the GTask is already finished, leading us to a SEGV. --- src/usb-acl-helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/usb-acl-helper.c b/src/usb-acl-helper.c index d1fdfbe..36d0418 100644 --- a/src/usb-acl-helper.c +++ b/src/usb-acl-helper.c @@ -38,6 +38,7 @@ struct _SpiceUsbAclHelperPrivate { GTask *task; GIOChannel *in_ch; GIOChannel *out_ch; + GCancellable *cancellable; gulong cancellable_id; }; @@ -52,8 +53,7 @@ static void spice_usb_acl_helper_cleanup(SpiceUsbAclHelper *self) { SpiceUsbAclHelperPrivate *priv = self->priv; - g_cancellable_disconnect(g_task_get_cancellable(priv->task), - priv->cancellable_id); + g_cancellable_disconnect(priv->cancellable, priv->cancellable_id); priv->cancellable_id = 0; g_clear_object(&priv->task); @@ -104,7 +104,6 @@ static gboolean cb_out_watch(GIOChannel *channel, SpiceUsbAclHelperPrivate *priv = self->priv; gboolean success = FALSE; GError *err = NULL; - GCancellable *cancellable; GIOStatus status; gchar *string; gsize size; @@ -144,8 +143,7 @@ static gboolean cb_out_watch(GIOChannel *channel, return TRUE; /* Wait for more input */ } - cancellable = g_task_get_cancellable(priv->task); - g_cancellable_disconnect(cancellable, priv->cancellable_id); + g_cancellable_disconnect(priv->cancellable, priv->cancellable_id); priv->cancellable_id = 0; if (!success) @@ -250,6 +248,7 @@ void spice_usb_acl_helper_open_acl(SpiceUsbAclHelper *self, priv->task = task; if (cancellable) { + priv->cancellable = cancellable; priv->cancellable_id = g_cancellable_connect(cancellable, G_CALLBACK(cancelled_cb), self, NULL); -- cgit