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

Jonathon Jongsma jjongsma at redhat.com
Thu Mar 24 20:29:23 UTC 2016


_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);
 }
 #endif
-- 
2.4.3



More information about the Spice-devel mailing list