diff options
author | Fabiano Fidêncio <fidencio@redhat.com> | 2016-03-23 03:50:40 +0100 |
---|---|---|
committer | Fabiano Fidêncio <fidencio@redhat.com> | 2016-03-23 04:22:37 +0100 |
commit | 0fa5895d6218269cce31315c36cb588c72a52fe0 (patch) | |
tree | c814ae20419b8c9715c93971d1a69f84aa0837eb /src/channel-usbredir.c | |
parent | f973df7e54b296f5cd2eca7498aea285a84ab007 (diff) | |
download | spice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.tar.gz spice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.tar.xz spice-gtk-0fa5895d6218269cce31315c36cb588c72a52fe0.zip |
Introduce gtask-helper.[ch]wip/gtask-helper
As noticed, GTask's heurestic for return a task in idle or immediately
doesn't work when using Coroutine and that's okay, we just need to do
the idle ourself. And in order to avoid code duplication, let's
introduce and make usage of the new g_task_helper_return_* functions.
These functions match exactly with the existing g_task_return_*
functions and the only difference is that they return on idle instead of
returning immediately.
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'src/channel-usbredir.c')
-rw-r--r-- | src/channel-usbredir.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c index 0f76126..174f37a 100644 --- a/src/channel-usbredir.c +++ b/src/channel-usbredir.c @@ -32,6 +32,8 @@ #include "usbutil.h" #endif +#include "gtask-helper.h" + #include "spice-client.h" #include "spice-common.h" @@ -296,14 +298,14 @@ static void spice_usbredir_channel_open_acl_cb( spice_usbredir_channel_open_device(channel, &err); } if (err) { - g_task_return_error(priv->task, err); + g_task_helper_return_error(priv->task, err); libusb_unref_device(priv->device); priv->device = NULL; g_boxed_free(spice_usb_device_get_type(), priv->spice_device); priv->spice_device = NULL; priv->state = STATE_DISCONNECTED; } else { - g_task_return_boolean(priv->task, TRUE); + g_task_helper_return_boolean(priv->task, TRUE); } g_clear_object(&priv->acl_helper); @@ -340,14 +342,14 @@ void spice_usbredir_channel_connect_device_async( task = g_task_new(channel, cancellable, callback, user_data); if (!priv->host) { - g_task_return_new_error(task, + g_task_helper_return_new_error(task, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "Error libusb context not set"); goto done; } if (priv->state != STATE_DISCONNECTED) { - g_task_return_new_error(task, + g_task_helper_return_new_error(task, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "Error channel is busy"); goto done; @@ -371,7 +373,7 @@ void spice_usbredir_channel_connect_device_async( return; #else if (!spice_usbredir_channel_open_device(channel, &err)) { - g_task_return_error(task, err); + g_task_helper_return_error(task, err); libusb_unref_device(priv->device); priv->device = NULL; g_boxed_free(spice_usb_device_get_type(), priv->spice_device); |