On Mon, Jan 18, 2016 at 11:39 AM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote: > On Mon, Jan 18, 2016 at 10:05:41AM +0100, Fabiano Fidêncio wrote: >> Instead of using GSimpleAsyncResult, use the new GTask API, which is >> much more straightforward. >> --- >> src/smartcard-manager.c | 33 +++++++++++++-------------------- >> 1 file changed, 13 insertions(+), 20 deletions(-) >> >> diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c >> index 6578328..2310ab6 100644 >> --- a/src/smartcard-manager.c >> +++ b/src/smartcard-manager.c >> @@ -476,8 +476,9 @@ end: >> return retval; >> } >> >> -static void smartcard_manager_init_helper(GSimpleAsyncResult *res, >> - GObject *object, >> +static void smartcard_manager_init_helper(GTask *task, >> + gpointer object, >> + gpointer task_data, >> GCancellable *cancellable) >> { >> static GOnce smartcard_manager_once = G_ONCE_INIT; >> @@ -492,8 +493,10 @@ static void smartcard_manager_init_helper(GSimpleAsyncResult *res, >> (GThreadFunc)smartcard_manager_init, >> &args); >> if (args.err != NULL) { >> - g_simple_async_result_set_from_error(res, args.err); >> + g_task_return_error(task, args.err); >> g_error_free(args.err); > > g_task_return_error() takes ownership of args.err, you cannot/do not > need to free it afterwards. Fixed locally. > >> + } else { >> + g_task_return_boolean(task, TRUE); >> } >> } >> >> @@ -504,17 +507,10 @@ void spice_smartcard_manager_init_async(SpiceSession *session, >> GAsyncReadyCallback callback, >> gpointer opaque) >> { >> - GSimpleAsyncResult *res; >> + GTask *task = g_task_new(session, cancellable, callback, opaque); >> >> - res = g_simple_async_result_new(G_OBJECT(session), >> - callback, >> - opaque, >> - spice_smartcard_manager_init); >> - g_simple_async_result_run_in_thread(res, >> - smartcard_manager_init_helper, >> - G_PRIORITY_DEFAULT, >> - cancellable); >> - g_object_unref(res); >> + g_task_run_in_thread(task, smartcard_manager_init_helper); >> + g_object_unref(task); >> } >> >> G_GNUC_INTERNAL >> @@ -522,21 +518,18 @@ gboolean spice_smartcard_manager_init_finish(SpiceSession *session, >> GAsyncResult *result, >> GError **err) >> { >> - GSimpleAsyncResult *simple; >> + GTask *task = G_TASK(result); >> >> g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE); >> - g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), FALSE); >> + g_return_val_if_fail(G_IS_TASK(task), FALSE); >> >> SPICE_DEBUG("smartcard_manager_finish"); >> >> - simple = G_SIMPLE_ASYNC_RESULT(result); >> - g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == spice_smartcard_manager_init, FALSE); >> - if (g_simple_async_result_propagate_error(simple, err)) >> - return FALSE; >> + g_return_val_if_fail(g_task_get_source_tag(task) == spice_smartcard_manager_init, FALSE); > > Is this check working? Don't you need to call g_task_set_source_tag() > for it to work? Good point, I have to check it, but my understanding is that you're right. I do have to call g_task_set_source_tag() for it to work. I will change that and submit a v2. > > Christophe _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel