[Spice-devel] [PATCH spice-gtk 1/2] SpiceUsbDeviceManager: propagate errors from sub-tasks

Christophe Fergeau cfergeau at redhat.com
Fri Mar 25 12:51:43 UTC 2016


On Thu, Mar 24, 2016 at 03:29:23PM -0500, Jonathon Jongsma wrote:
> _connect_device_async_cb() just turned TRUE unconditionally even if the
> sub-task had failed. Instad, introduce a
> _spice_usb_device_manager_connect_device_finish() function which passes
> up the result of the subtask.
> ---
>  src/usb-device-manager.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 1bbf6b3..cc95c68 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -1563,6 +1563,18 @@ _spice_usb_device_manager_uninstall_driver_async(SpiceUsbDeviceManager *self,
>  
>  #ifdef USE_USBREDIR
>  
> +static gboolean
> +_spice_usb_device_manager_connect_device_finish(SpiceUsbDeviceManager *self,
> +                                                GAsyncResult *res,
> +                                                GError **error)
> +{
> +    GTask *task = G_TASK(res);
> +
> +    g_return_val_if_fail(g_task_is_valid(task, G_OBJECT(self)), FALSE);
> +
> +    return g_task_propagate_boolean(task, error);
> +}
> +
>  static void
>  _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
>                                                 SpiceUsbDevice *device,
> @@ -1727,10 +1739,13 @@ void _connect_device_async_cb(GObject *gobject,
>  {
>      SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(gobject);
>      GTask *task = user_data;
> +    GError *error = NULL;
>  
>      _set_redirecting(self, FALSE);
> -
> -    g_task_return_boolean(task, TRUE);
> +    if (_spice_usb_device_manager_connect_device_finish(self, channel_res, &error))
> +        g_task_return_boolean(task, TRUE);
> +    else
> +        g_task_return_error(task, error);
>      g_object_unref(task);
>  }

This seems to be going on top of the usbdk series? I cannot find a
_connect_device_async_cb() in git master.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160325/f3fbf7f7/attachment.sig>


More information about the Spice-devel mailing list