diff options
author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2016-02-17 21:41:58 +0100 |
---|---|---|
committer | Fabiano FidĂȘncio <fidencio@redhat.com> | 2016-02-17 21:42:01 +0100 |
commit | 6fe5baa0cd9254d45a7cd13fa21aeb4df39e5274 (patch) | |
tree | 61dd2b50bc78f43255061bbcf8521fe81184f90f | |
parent | b2e6d2e1218b11dc458d827fe6a2ca8373b07986 (diff) | |
download | spice-gtk-6fe5baa0cd9254d45a7cd13fa21aeb4df39e5274.tar.gz spice-gtk-6fe5baa0cd9254d45a7cd13fa21aeb4df39e5274.tar.xz spice-gtk-6fe5baa0cd9254d45a7cd13fa21aeb4df39e5274.zip |
usb-acl-helper: bring the cancellable backgtask
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.
-rw-r--r-- | src/usb-acl-helper.c | 9 |
1 files 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); |