[gnome-control-center] printers: Use consistent GTask return pattern
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Use consistent GTask return pattern
- Date: Wed, 28 Nov 2018 11:56:36 +0000 (UTC)
commit bf463f2662c324afd5b5fc4aff9005d1278f926c
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 23 11:04:11 2018 +1300
printers: Use consistent GTask return pattern
panels/printers/pp-host.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index cbf4d0768..ec5f943fd 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -432,9 +432,8 @@ pp_host_get_remote_cups_devices_finish (PpHost *host,
typedef struct
{
- PpDevicesList *devices;
- PpHost *host;
- gint port;
+ PpHost *host;
+ gint port;
} JetDirectData;
static void
@@ -442,7 +441,6 @@ jetdirect_data_free (JetDirectData *data)
{
if (data != NULL)
{
- pp_devices_list_free (data->devices);
g_clear_object (&data->host);
g_free (data);
}
@@ -457,12 +455,14 @@ jetdirect_connection_test_cb (GObject *source_object,
PpHostPrivate *priv;
PpPrintDevice *device;
JetDirectData *data;
- gpointer result;
+ PpDevicesList *devices;
g_autoptr(GError) error = NULL;
GTask *task = G_TASK (user_data);
data = g_task_get_task_data (task);
+ devices = g_new0 (PpDevicesList, 1);
+
connection = g_socket_client_connect_to_host_finish (G_SOCKET_CLIENT (source_object),
res,
&error);
@@ -492,12 +492,10 @@ jetdirect_connection_test_cb (GObject *source_object,
g_free (device_uri);
- data->devices->devices = g_list_append (data->devices->devices, device);
+ devices->devices = g_list_append (devices->devices, device);
}
- result = data->devices;
- data->devices = NULL;
- g_task_return_pointer (task, result, (GDestroyNotify) pp_devices_list_free);
+ g_task_return_pointer (task, devices, (GDestroyNotify) pp_devices_list_free);
g_object_unref (task);
}
@@ -515,11 +513,9 @@ pp_host_get_jetdirect_devices_async (PpHost *host,
JetDirectData *data;
GTask *task;
gchar *address;
- gpointer result;
data = g_new0 (JetDirectData, 1);
data->host = g_object_ref (host);
- data->devices = g_new0 (PpDevicesList, 1);
if (priv->port == PP_HOST_UNSET_PORT)
data->port = PP_HOST_DEFAULT_JETDIRECT_PORT;
@@ -545,9 +541,7 @@ pp_host_get_jetdirect_devices_async (PpHost *host,
}
else
{
- result = data->devices;
- data->devices = NULL;
- g_task_return_pointer (task, result, (GDestroyNotify) pp_devices_list_free);
+ g_task_return_pointer (task, g_new0 (PpDevicesList, 1), (GDestroyNotify) pp_devices_list_free);
g_object_unref (task);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]