On Wed, Jul 01, 2015 at 09:40:47PM +0100, Zeeshan Ali (Khattak) wrote:
GSimpleAsyncResult has been deprecated in favour of GTask and with
latest glib headers, we get tons of warnings about use of deprecated
API. This patch ports the GVirConnection class to GTask.
---
libvirt-gobject/libvirt-gobject-connection.c | 246 ++++++++++++---------------
1 file changed, 110 insertions(+), 136 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c
b/libvirt-gobject/libvirt-gobject-connection.c
index dddbd3a..f7a6066 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -497,17 +497,18 @@ gboolean gvir_connection_open_read_only(GVirConnection *conn,
}
static void
-gvir_connection_open_helper(GSimpleAsyncResult *res,
- GObject *object,
+gvir_connection_open_helper(GTask *res,
I'd have a strong preference for "GTask *task" throughout the patch
rather than "GTask *res"
+ gpointer object,
+ gpointer task_data G_GNUC_UNUSED,
GCancellable *cancellable)
{
GVirConnection *conn = GVIR_CONNECTION(object);
GError *err = NULL;
- if (!gvir_connection_open(conn, cancellable, &err)) {
- g_simple_async_result_set_from_error(res, err);
- g_error_free(err);
- }
+ if (!gvir_connection_open(conn, cancellable, &err))
+ g_task_return_error(res, err);
+ else
+ g_task_return_boolean(res, TRUE);
}
@@ -523,19 +524,19 @@ void gvir_connection_open_async(GVirConnection *conn,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *res;
+ GTask *res;
g_return_if_fail(GVIR_IS_CONNECTION(conn));
g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
- res = g_simple_async_result_new(G_OBJECT(conn),
- callback,
- user_data,
- gvir_connection_open_async);
- g_simple_async_result_run_in_thread(res,
- gvir_connection_open_helper,
- G_PRIORITY_DEFAULT,
- cancellable);
+ res = g_task_new(G_OBJECT(conn),
+ cancellable,
+ callback,
+ user_data);
+ g_task_set_source_tag(res,
+ gvir_connection_open_async);
You set the source tag, but never use it, you're missing a
g_task_get_source_tag() check if the async complete callback.
[snip]
@@ -1760,21 +1744,18 @@
gvir_connection_restore_domain_from_file_async(GVirConnection *conn,
data->custom_conf = g_object_ref(custom_conf);
data->flags = flags;
- res = g_simple_async_result_new
- (G_OBJECT(conn),
- callback,
- user_data,
+ res = g_task_new (G_OBJECT(conn),
Nit: Extra space before opening parens
Christophe