libnm-glib: fix GAsyncInitable implementations

If a class implements init_async, it should implement init_finish too,
rather than assuming the default implementation will do the right
thing (which it briefly didn't in glib 2.33).
This commit is contained in:
Dan Winship
2012-07-17 09:41:15 -04:00
parent a03e7fb74f
commit 320464490e
4 changed files with 37 additions and 5 deletions

View File

@@ -1566,6 +1566,17 @@ init_async (GAsyncInitable *initable, int io_priority,
G_TYPE_INVALID); G_TYPE_INVALID);
} }
static gboolean
init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return TRUE;
}
static void static void
dispose (GObject *object) dispose (GObject *object)
{ {
@@ -1923,4 +1934,5 @@ nm_client_async_initable_iface_init (GAsyncInitableIface *iface)
nm_client_parent_async_initable_iface = g_type_interface_peek_parent (iface); nm_client_parent_async_initable_iface = g_type_interface_peek_parent (iface);
iface->init_async = init_async; iface->init_async = init_async;
iface->init_finish = init_finish;
} }

View File

@@ -205,14 +205,10 @@ init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
{ {
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
/* This is needed for now because of bug 667375; it can go away
* when we depend on glib >= 2.38
*/
if (g_simple_async_result_propagate_error (simple, error)) if (g_simple_async_result_propagate_error (simple, error))
return FALSE; return FALSE;
else else
return g_simple_async_result_get_op_res_gboolean (simple); return TRUE;
} }
static void static void

View File

@@ -448,6 +448,17 @@ init_async (GAsyncInitable *initable, int io_priority,
} }
static gboolean
init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return TRUE;
}
static void static void
nm_remote_connection_init (NMRemoteConnection *self) nm_remote_connection_init (NMRemoteConnection *self)
{ {
@@ -563,4 +574,5 @@ static void
nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface) nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface)
{ {
iface->init_async = init_async; iface->init_async = init_async;
iface->init_finish = init_finish;
} }

View File

@@ -1035,6 +1035,17 @@ init_async (GAsyncInitable *initable, int io_priority,
G_TYPE_INVALID); G_TYPE_INVALID);
} }
static gboolean
init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
else
return TRUE;
}
static void static void
dispose (GObject *object) dispose (GObject *object)
{ {
@@ -1198,4 +1209,5 @@ static void
nm_remote_settings_async_initable_iface_init (GAsyncInitableIface *iface) nm_remote_settings_async_initable_iface_init (GAsyncInitableIface *iface)
{ {
iface->init_async = init_async; iface->init_async = init_async;
iface->init_finish = init_finish;
} }