diff options
author | Benjamin Berg <bberg@redhat.com> | 2018-03-05 16:02:24 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-03-08 14:52:45 +0100 |
commit | 26c215e22dcfff9e61a58e9348991ed77c3f8861 (patch) | |
tree | ab7cbe276d8fc3dcc12ed677294fa0c85396f94f /libnm-glib | |
parent | d76cfa3814915cc12c7af9e7bdc4d7ac3dc71e49 (diff) |
Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.
Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.
https://bugzilla.gnome.org/show_bug.cgi?id=794088
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/nm-client.c | 6 | ||||
-rw-r--r-- | libnm-glib/nm-object.c | 2 | ||||
-rw-r--r-- | libnm-glib/nm-remote-connection.c | 2 | ||||
-rw-r--r-- | libnm-glib/nm-remote-settings.c | 4 |
4 files changed, 14 insertions, 0 deletions
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 183cdc933..ad9069836 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -1612,6 +1612,8 @@ nm_client_check_connectivity_async (NMClient *client, simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, nm_client_check_connectivity_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_op_res_gpointer (simple, ccd, (GDestroyNotify) check_connectivity_data_free); if (cancellable) { @@ -1738,6 +1740,8 @@ nm_client_new_async (GCancellable *cancellable, } simple = g_simple_async_result_new (NULL, callback, user_data, nm_client_new_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); g_async_initable_init_async (G_ASYNC_INITABLE (client), G_PRIORITY_DEFAULT, cancellable, client_inited, simple); } @@ -2001,6 +2005,8 @@ init_async (GAsyncInitable *initable, int io_priority, init_data->client = NM_CLIENT (initable); init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (init_data->result, cancellable); g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE); /* Check if NM is running */ diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 2e07ff6d1..d3f8c830e 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -303,6 +303,8 @@ init_async (GAsyncInitable *initable, int io_priority, GSimpleAsyncResult *simple; simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); /* Check if NM is running */ dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner", diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 7e60ea953..820f9e5ca 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -713,6 +713,8 @@ init_async (GAsyncInitable *initable, int io_priority, init_data->connection = NM_REMOTE_CONNECTION (initable); init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (init_data->result, cancellable); dbus_g_proxy_begin_call (priv->proxy, "GetSettings", init_get_settings_cb, init_data, NULL, diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 3f2c50f24..be6b7ee3b 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -1115,6 +1115,8 @@ nm_remote_settings_new_async (DBusGConnection *bus, GCancellable *cancellable, GSimpleAsyncResult *simple; simple = g_simple_async_result_new (NULL, callback, user_data, nm_remote_settings_new_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); self = g_object_new (NM_TYPE_REMOTE_SETTINGS, NM_REMOTE_SETTINGS_BUS, bus, @@ -1367,6 +1369,8 @@ init_async (GAsyncInitable *initable, int io_priority, init_data->settings = NM_REMOTE_SETTINGS (initable); init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async); + if (cancellable) + g_simple_async_result_set_check_cancellable (init_data->result, cancellable); /* Check if NM is running */ dbus_g_proxy_begin_call (priv->dbus_proxy, "NameHasOwner", |