[gnome-control-center] printers: Use g_autoptr for GError handling
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Use g_autoptr for GError handling
- Date: Mon, 17 Sep 2018 15:26:07 +0000 (UTC)
commit 877445cbafd742b2c4abd7124c83919b47ff5743
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Jun 26 10:40:43 2018 +1200
printers: Use g_autoptr for GError handling
panels/printers/cc-printers-panel.c | 18 +-
panels/printers/pp-host.c | 34 ++--
panels/printers/pp-job.c | 10 +-
panels/printers/pp-jobs-dialog.c | 50 +++---
panels/printers/pp-new-printer-dialog.c | 53 ++----
panels/printers/pp-new-printer.c | 101 +++++------
panels/printers/pp-options-dialog.c | 11 +-
panels/printers/pp-ppd-selection-dialog.c | 3 +-
panels/printers/pp-printer-entry.c | 19 +--
panels/printers/pp-printer.c | 42 +++--
panels/printers/pp-utils.c | 272 +++++++++++++-----------------
11 files changed, 249 insertions(+), 364 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index f05a3ec6d..a2566a022 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -269,16 +269,13 @@ printer_removed_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
pp_printer_delete_finish (PP_PRINTER (source_object), result, &error);
g_object_unref (source_object);
if (error != NULL)
- {
- g_warning ("Printer could not be deleted: %s", error->message);
- g_error_free (error);
- }
+ g_warning ("Printer could not be deleted: %s", error->message);
}
static void
@@ -416,7 +413,7 @@ on_get_job_attributes_cb (GObject *source_object,
GVariant *attributes;
GVariant *username;
GVariant *printer_uri;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
priv = PRINTERS_PANEL_PRIVATE (self);
@@ -595,7 +592,7 @@ attach_to_cups_notifier_cb (GObject *source_object,
CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
PpCups *cups = PP_CUPS (source_object);
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gint subscription_id;
subscription_id = pp_cups_renew_subscription_finish (cups, result);
@@ -621,7 +618,6 @@ attach_to_cups_notifier_cb (GObject *source_object,
if (!priv->cups_proxy)
{
g_warning ("%s", error->message);
- g_error_free (error);
return;
}
@@ -921,7 +917,7 @@ actualize_printers_list_cb (GObject *source_object,
PpCups *cups = PP_CUPS (source_object);
PpCupsDests *cups_dests;
gboolean new_printer_available = FALSE;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
int i;
cups_dests = pp_cups_get_dests_finish (cups, result, &error);
@@ -933,7 +929,6 @@ actualize_printers_list_cb (GObject *source_object,
g_warning ("Could not get dests: %s", error->message);
}
- g_error_free (error);
g_object_unref (cups);
return;
}
@@ -1338,7 +1333,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
GtkWidget *top_widget;
GtkWidget *widget;
PpCups *cups;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar *objects[] = { "overlay", "headerbar-buttons", "search-button", NULL };
guint builder_result;
@@ -1392,7 +1387,6 @@ cc_printers_panel_init (CcPrintersPanel *self)
{
/* Translators: The XML file containing user interface can not be loaded */
g_warning (_("Could not load ui: %s"), error->message);
- g_error_free (error);
return;
}
diff --git a/panels/printers/pp-host.c b/panels/printers/pp-host.c
index 8af77e9a9..70b447c8c 100644
--- a/panels/printers/pp-host.c
+++ b/panels/printers/pp-host.c
@@ -251,16 +251,16 @@ _pp_host_get_snmp_devices_thread (GSimpleAsyncResult *res,
GObject *object,
GCancellable *cancellable)
{
- PpHost *host = (PpHost *) object;
- PpHostPrivate *priv = host->priv;
- PpPrintDevice *device;
- gboolean is_network_device;
- GSDData *data;
- GError *error;
- gchar **argv;
- gchar *stdout_string = NULL;
- gchar *stderr_string = NULL;
- gint exit_status;
+ PpHost *host = (PpHost *) object;
+ PpHostPrivate *priv = host->priv;
+ PpPrintDevice *device;
+ gboolean is_network_device;
+ GSDData *data;
+ g_autoptr(GError) error = NULL;
+ gchar **argv;
+ gchar *stdout_string = NULL;
+ gchar *stderr_string = NULL;
+ gint exit_status;
data = g_simple_async_result_get_op_res_gpointer (res);
data->devices = g_new0 (PpDevicesList, 1);
@@ -510,7 +510,7 @@ jetdirect_connection_test_cb (GObject *source_object,
PpPrintDevice *device;
JetDirectData *data;
gpointer result;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GTask *task = G_TASK (user_data);
data = g_task_get_task_data (task);
@@ -625,7 +625,7 @@ test_lpd_queue (GSocketClient *client,
{
GSocketConnection *connection;
gboolean result = FALSE;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
connection = g_socket_client_connect_to_host (client,
address,
@@ -679,14 +679,6 @@ test_lpd_queue (GSocketClient *client,
result = TRUE;
}
}
- else
- {
- g_clear_error (&error);
- }
- }
- else
- {
- g_clear_error (&error);
}
}
@@ -710,7 +702,7 @@ _pp_host_get_lpd_devices_thread (GTask *task,
GSocketClient *client;
PpDevicesList *result;
GSDData *data = (GSDData *) task_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GList *candidates = NULL;
GList *iter;
gchar *found_queue = NULL;
diff --git a/panels/printers/pp-job.c b/panels/printers/pp-job.c
index 0c04c4f35..4bfa8154d 100644
--- a/panels/printers/pp-job.c
+++ b/panels/printers/pp-job.c
@@ -90,7 +90,7 @@ pp_job_cancel_purge_async (PpJob *job,
gboolean job_purge)
{
GDBusConnection *bus;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gint *job_id;
g_object_get (job, "id", &job_id, NULL);
@@ -99,7 +99,6 @@ pp_job_cancel_purge_async (PpJob *job,
if (!bus)
{
g_warning ("Failed to get session bus: %s", error->message);
- g_error_free (error);
return;
}
@@ -141,9 +140,9 @@ void
pp_job_set_hold_until_async (PpJob *job,
const gchar *job_hold_until)
{
- GDBusConnection *bus;
- GError *error = NULL;
- gint *job_id;
+ GDBusConnection *bus;
+ g_autoptr(GError) error = NULL;
+ gint *job_id;
g_object_get (job, "id", &job_id, NULL);
@@ -151,7 +150,6 @@ pp_job_set_hold_until_async (PpJob *job,
if (!bus)
{
g_warning ("Failed to get session bus: %s", error->message);
- g_error_free (error);
return;
}
diff --git a/panels/printers/pp-jobs-dialog.c b/panels/printers/pp-jobs-dialog.c
index c5e9e9f02..e3956e5c8 100644
--- a/panels/printers/pp-jobs-dialog.c
+++ b/panels/printers/pp-jobs-dialog.c
@@ -317,18 +317,18 @@ update_jobs_list_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- PpJobsDialog *dialog = user_data;
- PpPrinter *printer = PP_PRINTER (source_object);
- GtkWidget *clear_all_button;
- GtkWidget *infobar;
- GtkWidget *label;
- GtkStack *stack;
- GError *error = NULL;
- GList *jobs, *l;
- PpJob *job;
- gchar **auth_info_required = NULL;
- gchar *text;
- gint num_of_jobs, num_of_auth_jobs = 0;
+ PpJobsDialog *dialog = user_data;
+ PpPrinter *printer = PP_PRINTER (source_object);
+ GtkWidget *clear_all_button;
+ GtkWidget *infobar;
+ GtkWidget *label;
+ GtkStack *stack;
+ g_autoptr(GError) error = NULL;
+ GList *jobs, *l;
+ PpJob *job;
+ gchar **auth_info_required = NULL;
+ gchar *text;
+ gint num_of_jobs, num_of_auth_jobs = 0;
g_list_store_remove_all (dialog->store);
@@ -343,7 +343,6 @@ update_jobs_list_cb (GObject *source_object,
g_warning ("Could not get jobs: %s", error->message);
}
- g_error_free (error);
return;
}
@@ -474,10 +473,10 @@ pp_job_authenticate_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpJobsDialog *dialog = user_data;
- gboolean result;
- GError *error = NULL;
- PpJob *job = PP_JOB (source_object);
+ PpJobsDialog *dialog = user_data;
+ gboolean result;
+ g_autoptr(GError) error = NULL;
+ PpJob *job = PP_JOB (source_object);
result = pp_job_authenticate_finish (job, res, &error);
if (result)
@@ -490,8 +489,6 @@ pp_job_authenticate_cb (GObject *source_object,
{
g_warning ("Could not authenticate job: %s", error->message);
}
-
- g_error_free (error);
}
}
@@ -558,13 +555,13 @@ pp_jobs_dialog_new (GtkWindow *parent,
gpointer user_data,
gchar *printer_name)
{
- PpJobsDialog *dialog;
- GtkWidget *widget;
- GError *error = NULL;
- gchar *objects[] = { "jobs-dialog", "authentication_popover", NULL };
- gchar *text;
- guint builder_result;
- gchar *title;
+ PpJobsDialog *dialog;
+ GtkWidget *widget;
+ g_autoptr(GError) error = NULL;
+ gchar *objects[] = { "jobs-dialog", "authentication_popover", NULL };
+ gchar *text;
+ guint builder_result;
+ gchar *title;
dialog = g_new0 (PpJobsDialog, 1);
@@ -578,7 +575,6 @@ pp_jobs_dialog_new (GtkWindow *parent,
if (builder_result == 0)
{
g_warning ("Could not load ui: %s", error->message);
- g_error_free (error);
return NULL;
}
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index f7cdfd8f8..77576d529 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -264,7 +264,7 @@ get_authenticated_samba_devices_cb (GObject *source_object,
GtkWidget *widget;
gboolean cancelled = FALSE;
PpSamba *samba = (PpSamba *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GList *iter;
g_object_ref (samba);
@@ -324,8 +324,6 @@ get_authenticated_samba_devices_cb (GObject *source_object,
priv->samba_authenticated_searching = FALSE;
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
g_free (data->server_name);
@@ -526,7 +524,7 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
PpNewPrinterDialogPrivate *priv;
GtkStyleContext *context;
GtkWidget *widget;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar *objects[] = { "dialog",
"devices-liststore",
"devices-model-filter",
@@ -545,7 +543,6 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
if (builder_result == 0)
{
g_warning ("Could not load ui: %s", error->message);
- g_error_free (error);
}
/* GCancellable for cancelling of async operations */
@@ -975,10 +972,10 @@ group_physical_devices_dbus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- GError *error = NULL;
- gchar ***result = NULL;
- gint i, j;
+ GVariant *output;
+ g_autoptr(GError) error = NULL;
+ gchar ***result = NULL;
+ gint i, j;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -1045,9 +1042,6 @@ DBus method \"GroupPhysicalDevices\" to group duplicates in device list.");
error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
group_physical_devices_cb (result, user_data);
-
- if (error)
- g_error_free (error);
}
static void
@@ -1067,7 +1061,7 @@ get_cups_devices_cb (GList *devices,
const gchar *device_class;
GtkTreeIter iter;
gboolean cont;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
GList *liter;
gint length, i;
@@ -1183,7 +1177,6 @@ get_cups_devices_cb (GList *devices,
else
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
group_physical_devices_cb (NULL, user_data);
}
@@ -1213,7 +1206,7 @@ get_snmp_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
PpDevicesList *result;
result = pp_host_get_snmp_devices_finish (host, res, &error);
@@ -1248,8 +1241,6 @@ get_snmp_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1261,7 +1252,7 @@ get_remote_cups_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
PpDevicesList *result;
result = pp_host_get_remote_cups_devices_finish (host, res, &error);
@@ -1296,8 +1287,6 @@ get_remote_cups_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1310,7 +1299,7 @@ get_samba_host_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
result = pp_samba_get_devices_finish (samba, res, &error);
g_object_unref (source_object);
@@ -1344,8 +1333,6 @@ get_samba_host_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1358,7 +1345,7 @@ get_samba_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
result = pp_samba_get_devices_finish (samba, res, &error);
g_object_unref (source_object);
@@ -1390,8 +1377,6 @@ get_samba_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1403,7 +1388,7 @@ get_jetdirect_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
PpDevicesList *result;
result = pp_host_get_jetdirect_devices_finish (host, res, &error);
@@ -1437,8 +1422,6 @@ get_jetdirect_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1450,7 +1433,7 @@ get_lpd_devices_cb (GObject *source_object,
PpNewPrinterDialog *dialog;
PpNewPrinterDialogPrivate *priv;
PpHost *host = (PpHost *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
PpDevicesList *result;
result = pp_host_get_lpd_devices_finish (host, res, &error);
@@ -1484,8 +1467,6 @@ get_lpd_devices_cb (GObject *source_object,
update_dialog_state (dialog);
}
-
- g_error_free (error);
}
}
@@ -1950,7 +1931,7 @@ cups_get_dests_cb (GObject *source_object,
PpNewPrinterDialogPrivate *priv;
PpCupsDests *dests;
PpCups *cups = (PpCups *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
dests = pp_cups_get_dests_finish (cups, res, &error);
g_object_unref (source_object);
@@ -1976,8 +1957,6 @@ cups_get_dests_cb (GObject *source_object,
get_cups_devices (dialog);
}
-
- g_error_free (error);
}
}
@@ -2134,7 +2113,7 @@ printer_add_async_cb (GObject *source_object,
GtkResponseType response_id = GTK_RESPONSE_OK;
PpNewPrinter *new_printer = (PpNewPrinter *) source_object;
gboolean success;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
success = pp_new_printer_add_finish (new_printer, res, &error);
g_object_unref (source_object);
@@ -2158,8 +2137,6 @@ printer_add_async_cb (GObject *source_object,
emit_response (dialog, response_id);
}
-
- g_error_free (error);
}
}
diff --git a/panels/printers/pp-new-printer.c b/panels/printers/pp-new-printer.c
index e1e480817..0c2177743 100644
--- a/panels/printers/pp-new-printer.c
+++ b/panels/printers/pp-new-printer.c
@@ -411,7 +411,7 @@ printer_add_real_async_dbus_cb (GObject *source_object,
PpNewPrinter *printer = (PpNewPrinter *) user_data;
PpNewPrinterPrivate *priv = printer->priv;
GVariant *output;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -445,9 +445,6 @@ printer_add_real_async_dbus_cb (GObject *source_object,
printer_add_real_async_cb,
printer);
}
-
- if (error)
- g_error_free (error);
}
static void
@@ -455,7 +452,7 @@ printer_add_real_async (PpNewPrinter *printer)
{
PpNewPrinterPrivate *priv = printer->priv;
GDBusConnection *bus;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
if (!priv->ppd_name && !priv->ppd_file_name)
{
@@ -467,7 +464,6 @@ printer_add_real_async (PpNewPrinter *printer)
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
_pp_new_printer_add_async_cb (FALSE, printer);
return;
}
@@ -560,7 +556,7 @@ printer_add_async_scb3 (GObject *source_object,
PpNewPrinterPrivate *priv = printer->priv;
GVariant *output;
PPDName *ppd_item = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -592,11 +588,6 @@ printer_add_async_scb3 (GObject *source_object,
_pp_new_printer_add_async_cb (FALSE, printer);
}
- if (error)
- {
- g_error_free (error);
- }
-
if (ppd_item)
{
g_free (ppd_item->ppd_name);
@@ -612,7 +603,7 @@ install_printer_drivers_cb (GObject *source_object,
PpNewPrinterPrivate *priv;
PpNewPrinter *printer;
GVariant *output;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -634,14 +625,14 @@ install_printer_drivers_cb (GObject *source_object,
error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
{
- GDBusConnection *bus;
- GError *error = NULL;
+ GDBusConnection *bus;
+ g_autoptr(GError) bus_error = NULL;
printer = (PpNewPrinter *) user_data;
priv = printer->priv;
/* Try whether CUPS has a driver for the new printer */
- bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &bus_error);
if (bus)
{
g_dbus_connection_call (bus,
@@ -662,14 +653,10 @@ install_printer_drivers_cb (GObject *source_object,
}
else
{
- g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
+ g_warning ("Failed to get system bus: %s", bus_error->message);
_pp_new_printer_add_async_cb (FALSE, printer);
}
}
-
- if (error)
- g_error_free (error);
}
static void
@@ -684,7 +671,7 @@ printer_add_async_scb (GObject *source_object,
GVariant *output;
gboolean cancelled = FALSE;
PPDName *ppd_item = NULL;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -702,15 +689,15 @@ printer_add_async_scb (GObject *source_object,
if (!cancelled)
g_warning ("%s", error->message);
-
- g_clear_error (&error);
}
if (!cancelled)
{
if (ppd_item == NULL || ppd_item->ppd_match_level < PPD_EXACT_MATCH)
{
- bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ g_autoptr(GError) bus_error = NULL;
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &bus_error);
if (bus)
{
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
@@ -734,8 +721,7 @@ printer_add_async_scb (GObject *source_object,
}
else
{
- g_warning ("Failed to get session bus: %s", error->message);
- g_error_free (error);
+ g_warning ("Failed to get session bus: %s", bus_error->message);
_pp_new_printer_add_async_cb (FALSE, printer);
}
}
@@ -843,9 +829,9 @@ printer_set_accepting_jobs_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- PCData *data = (PCData *) user_data;
- GError *error = NULL;
+ GVariant *output;
+ PCData *data = (PCData *) user_data;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -861,7 +847,6 @@ printer_set_accepting_jobs_cb (GObject *source_object,
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
data->set_accept_jobs_finished = TRUE;
@@ -873,9 +858,9 @@ printer_set_enabled_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- PCData *data = (PCData *) user_data;
- GError *error = NULL;
+ GVariant *output;
+ PCData *data = (PCData *) user_data;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -891,7 +876,6 @@ printer_set_enabled_cb (GObject *source_object,
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
data->set_enabled_finished = TRUE;
@@ -945,9 +929,9 @@ install_package_names_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- IMEData *data = (IMEData *) user_data;
- GError *error = NULL;
+ GVariant *output;
+ IMEData *data = (IMEData *) user_data;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -963,7 +947,6 @@ install_package_names_cb (GObject *source_object,
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
install_missing_executables_cb (data);
@@ -975,10 +958,10 @@ search_files_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- IMEData *data = (IMEData *) user_data;
- GError *error = NULL;
- GList *item;
+ GVariant *output;
+ IMEData *data = (IMEData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *item;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -1002,7 +985,6 @@ search_files_cb (GObject *source_object,
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
if (data->executables)
@@ -1075,11 +1057,11 @@ get_missing_executables_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- IMEData *data = (IMEData *) user_data;
- GError *error = NULL;
- GList *executables = NULL;
- GList *item;
+ GVariant *output;
+ IMEData *data = (IMEData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *executables = NULL;
+ GList *item;
if (data->ppd_file_name)
{
@@ -1122,14 +1104,12 @@ get_missing_executables_cb (GObject *source_object,
{
g_warning ("Install system-config-printer which provides \
DBus method \"MissingExecutables\" to find missing executables and filters.");
- g_error_free (error);
}
else
{
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
executables = g_list_sort (executables, (GCompareFunc) g_strcmp0);
@@ -1169,9 +1149,9 @@ static void
printer_get_ppd_cb (const gchar *ppd_filename,
gpointer user_data)
{
- GDBusConnection *bus;
- IMEData *data = (IMEData *) user_data;
- GError *error = NULL;
+ GDBusConnection *bus;
+ IMEData *data = (IMEData *) user_data;
+ g_autoptr(GError) error = NULL;
data->ppd_file_name = g_strdup (ppd_filename);
if (data->ppd_file_name)
@@ -1180,7 +1160,6 @@ printer_get_ppd_cb (const gchar *ppd_filename,
if (!bus)
{
g_warning ("%s", error->message);
- g_error_free (error);
}
else
{
@@ -1209,7 +1188,7 @@ pp_maintenance_command_execute_cb (GObject *source_object,
gpointer user_data)
{
PpMaintenanceCommand *command = (PpMaintenanceCommand *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
PCData *data;
gboolean result;
@@ -1235,8 +1214,6 @@ pp_maintenance_command_execute_cb (GObject *source_object,
data->autoconfigure_finished = TRUE;
printer_configure_async_finish (data);
}
-
- g_error_free (error);
}
}
@@ -1248,7 +1225,7 @@ printer_configure_async (PpNewPrinter *new_printer)
PCData *data;
IMEData *ime_data;
gchar **values;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
data = g_new0 (PCData, 1);
data->new_printer = new_printer;
@@ -1298,7 +1275,6 @@ printer_configure_async (PpNewPrinter *new_printer)
else
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
data->set_accept_jobs_finished = TRUE;
data->set_enabled_finished = TRUE;
}
@@ -1365,8 +1341,8 @@ _pp_new_printer_add_async (GSimpleAsyncResult *res,
}
else if (priv->device_id)
{
- GDBusConnection *bus;
- GError *error = NULL;
+ GDBusConnection *bus;
+ g_autoptr(GError) error = NULL;
/* Try whether CUPS has a driver for the new printer */
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
@@ -1391,7 +1367,6 @@ _pp_new_printer_add_async (GSimpleAsyncResult *res,
else
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
_pp_new_printer_add_async_cb (FALSE, printer);
}
}
diff --git a/panels/printers/pp-options-dialog.c b/panels/printers/pp-options-dialog.c
index 366808f80..f789dd986 100644
--- a/panels/printers/pp-options-dialog.c
+++ b/panels/printers/pp-options-dialog.c
@@ -933,11 +933,11 @@ pp_options_dialog_new (GtkWindow *parent,
gchar *printer_name,
gboolean sensitive)
{
- PpOptionsDialog *dialog;
- GtkWidget *test_page_button;
- GError *error = NULL;
- gchar *objects[] = { "options-dialog", NULL };
- guint builder_result;
+ PpOptionsDialog *dialog;
+ GtkWidget *test_page_button;
+ g_autoptr(GError) error = NULL;
+ gchar *objects[] = { "options-dialog", NULL };
+ guint builder_result;
dialog = g_new0 (PpOptionsDialog, 1);
@@ -951,7 +951,6 @@ pp_options_dialog_new (GtkWindow *parent,
if (builder_result == 0)
{
g_warning ("Could not load ui: %s", error->message);
- g_error_free (error);
return NULL;
}
diff --git a/panels/printers/pp-ppd-selection-dialog.c b/panels/printers/pp-ppd-selection-dialog.c
index 6851fc65a..62f9ae64c 100644
--- a/panels/printers/pp-ppd-selection-dialog.c
+++ b/panels/printers/pp-ppd-selection-dialog.c
@@ -333,7 +333,7 @@ pp_ppd_selection_dialog_new (GtkWindow *parent,
{
PpPPDSelectionDialog *dialog;
GtkWidget *widget;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gchar *objects[] = { "ppd-selection-dialog", NULL };
guint builder_result;
@@ -349,7 +349,6 @@ pp_ppd_selection_dialog_new (GtkWindow *parent,
if (builder_result == 0)
{
g_warning ("Could not load ui: %s", error->message);
- g_error_free (error);
return NULL;
}
diff --git a/panels/printers/pp-printer-entry.c b/panels/printers/pp-printer-entry.c
index 8907ca9d6..c4360aa92 100644
--- a/panels/printers/pp-printer-entry.c
+++ b/panels/printers/pp-printer-entry.c
@@ -507,13 +507,12 @@ check_clean_heads_maintenance_command_cb (GObject *source_object,
{
PpMaintenanceCommand *command = (PpMaintenanceCommand *) source_object;
gboolean is_supported = FALSE;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
is_supported = pp_maintenance_command_is_supported_finish (command, res, &error);
if (error != NULL)
{
g_debug ("Could not check 'Clean' maintenance command: %s", error->message);
- g_error_free (error);
goto out;
}
@@ -549,12 +548,11 @@ clean_heads_maintenance_command_cb (GObject *source_object,
{
PpPrinterEntry *self = PP_PRINTER_ENTRY (user_data);
PpMaintenanceCommand *command = (PpMaintenanceCommand *) source_object;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
if (!pp_maintenance_command_execute_finish (command, res, &error))
{
g_warning ("Error cleaning print heads for %s: %s", self->printer_name, error->message);
- g_error_free (error);
}
g_object_unref (source_object);
}
@@ -585,12 +583,12 @@ get_jobs_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- PpPrinterEntry *self;
- PpPrinter *printer = PP_PRINTER (source_object);
- GError *error = NULL;
- GList *jobs;
- gchar *button_label;
- gint num_jobs;
+ PpPrinterEntry *self;
+ PpPrinter *printer = PP_PRINTER (source_object);
+ g_autoptr(GError) error = NULL;
+ GList *jobs;
+ gchar *button_label;
+ gint num_jobs;
jobs = pp_printer_get_jobs_finish (printer, result, &error);
num_jobs = g_list_length (jobs);
@@ -605,7 +603,6 @@ get_jobs_cb (GObject *source_object,
g_warning ("Could not get jobs: %s", error->message);
}
- g_error_free (error);
return;
}
diff --git a/panels/printers/pp-printer.c b/panels/printers/pp-printer.c
index 87be522db..e85ad6a5c 100644
--- a/panels/printers/pp-printer.c
+++ b/panels/printers/pp-printer.c
@@ -168,12 +168,12 @@ printer_rename_dbus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- PpPrinter *printer;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
- GTask *task = user_data;
- gchar *old_printer_name;
+ PpPrinter *printer;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
+ GTask *task = user_data;
+ gchar *old_printer_name;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -210,7 +210,6 @@ printer_rename_dbus_cb (GObject *source_object,
error->code == G_DBUS_ERROR_UNKNOWN_METHOD))
{
g_warning ("Update cups-pk-helper to at least 0.2.6 please to be able to use PrinterRename
method.");
- g_error_free (error);
g_task_run_in_thread (task, printer_rename_thread);
}
@@ -226,10 +225,10 @@ get_bus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GDBusConnection *bus;
- GError *error = NULL;
- GTask *task = user_data;
- gchar *printer_name;
+ GDBusConnection *bus;
+ g_autoptr(GError) error = NULL;
+ GTask *task = user_data;
+ gchar *printer_name;
bus = g_bus_get_finish (res, &error);
if (bus != NULL)
@@ -257,7 +256,6 @@ get_bus_cb (GObject *source_object,
else
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
g_task_return_boolean (task, FALSE);
}
}
@@ -447,11 +445,11 @@ pp_printer_delete_dbus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
- GTask *task = user_data;
- gchar *printer_name;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
+ GTask *task = user_data;
+ gchar *printer_name;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -478,7 +476,6 @@ pp_printer_delete_dbus_cb (GObject *source_object,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
g_task_return_boolean (task, FALSE);
}
@@ -489,10 +486,10 @@ pp_printer_delete_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GDBusConnection *bus;
- GError *error = NULL;
- GTask *task = user_data;
- gchar *printer_name;
+ GDBusConnection *bus;
+ g_autoptr(GError) error = NULL;
+ GTask *task = user_data;
+ gchar *printer_name;
bus = g_bus_get_finish (res, &error);
if (bus != NULL)
@@ -519,7 +516,6 @@ pp_printer_delete_cb (GObject *source_object,
else
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
g_task_return_boolean (task, FALSE);
}
}
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 68eaa9871..f677a38c9 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -273,7 +273,7 @@ printer_rename (const gchar *old_name,
gboolean printer_paused = FALSE;
gboolean default_printer = FALSE;
gboolean printer_shared = FALSE;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
http_t *http;
gchar *ppd_link;
gchar *ppd_filename = NULL;
@@ -446,7 +446,6 @@ printer_rename (const gchar *old_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
}
else
{
@@ -458,7 +457,8 @@ printer_rename (const gchar *old_name,
}
else
{
- GVariant *output;
+ GVariant *output;
+ g_autoptr(GError) add_error = NULL;
output = g_dbus_connection_call_sync (bus,
MECHANISM_BUS,
@@ -475,7 +475,7 @@ printer_rename (const gchar *old_name,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
- &error);
+ &add_error);
g_object_unref (bus);
if (output)
@@ -490,8 +490,7 @@ printer_rename (const gchar *old_name,
}
else
{
- g_warning ("%s", error->message);
- g_error_free (error);
+ g_warning ("%s", add_error->message);
}
}
}
@@ -542,10 +541,10 @@ gboolean
printer_set_location (const gchar *printer_name,
const gchar *location)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name || !location)
return TRUE;
@@ -554,7 +553,6 @@ printer_set_location (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -586,7 +584,6 @@ printer_set_location (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -597,10 +594,10 @@ printer_set_accepting_jobs (const gchar *printer_name,
gboolean accepting_jobs,
const gchar *reason)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name)
return TRUE;
@@ -609,7 +606,6 @@ printer_set_accepting_jobs (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -643,7 +639,6 @@ printer_set_accepting_jobs (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -653,10 +648,10 @@ gboolean
printer_set_enabled (const gchar *printer_name,
gboolean enabled)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name)
return TRUE;
@@ -665,7 +660,6 @@ printer_set_enabled (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -697,7 +691,6 @@ printer_set_enabled (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -706,10 +699,10 @@ printer_set_enabled (const gchar *printer_name,
gboolean
printer_delete (const gchar *printer_name)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name)
return TRUE;
@@ -718,7 +711,6 @@ printer_delete (const gchar *printer_name)
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -750,7 +742,6 @@ printer_delete (const gchar *printer_name)
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -759,11 +750,11 @@ printer_delete (const gchar *printer_name)
gboolean
printer_set_default (const gchar *printer_name)
{
- GDBusConnection *bus;
- const char *cups_server;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ const char *cups_server;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name)
return TRUE;
@@ -783,7 +774,6 @@ printer_set_default (const gchar *printer_name)
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
}
else
{
@@ -815,7 +805,6 @@ printer_set_default (const gchar *printer_name)
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
}
}
@@ -834,10 +823,10 @@ gboolean
printer_set_shared (const gchar *printer_name,
gboolean shared)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name)
return TRUE;
@@ -846,7 +835,6 @@ printer_set_shared (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -878,7 +866,6 @@ printer_set_shared (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -889,10 +876,10 @@ printer_set_job_sheets (const gchar *printer_name,
const gchar *start_sheet,
const gchar *end_sheet)
{
- GDBusConnection *bus;
- GVariant *output;
- GError *error = NULL;
- gboolean result = FALSE;
+ GDBusConnection *bus;
+ GVariant *output;
+ g_autoptr(GError) error = NULL;
+ gboolean result = FALSE;
if (!printer_name || !start_sheet || !end_sheet)
return TRUE;
@@ -901,7 +888,6 @@ printer_set_job_sheets (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -933,7 +919,6 @@ printer_set_job_sheets (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -944,10 +929,10 @@ printer_set_policy (const gchar *printer_name,
const gchar *policy,
gboolean error_policy)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name || !policy)
return TRUE;
@@ -956,7 +941,6 @@ printer_set_policy (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -1001,7 +985,6 @@ printer_set_policy (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -1012,12 +995,12 @@ printer_set_users (const gchar *printer_name,
gchar **users,
gboolean allowed)
{
- GDBusConnection *bus;
- GVariantBuilder array_builder;
- gint i;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariantBuilder array_builder;
+ gint i;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!printer_name || !users)
return TRUE;
@@ -1026,7 +1009,6 @@ printer_set_users (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -1075,7 +1057,6 @@ printer_set_users (const gchar *printer_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -1085,10 +1066,10 @@ gboolean
class_add_printer (const gchar *class_name,
const gchar *printer_name)
{
- GDBusConnection *bus;
- GVariant *output;
- gboolean result = FALSE;
- GError *error = NULL;
+ GDBusConnection *bus;
+ GVariant *output;
+ gboolean result = FALSE;
+ g_autoptr(GError) error = NULL;
if (!class_name || !printer_name)
return TRUE;
@@ -1097,7 +1078,6 @@ class_add_printer (const gchar *class_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
return TRUE;
}
@@ -1129,7 +1109,6 @@ class_add_printer (const gchar *class_name,
else
{
g_warning ("%s", error->message);
- g_error_free (error);
}
return result;
@@ -1411,9 +1390,9 @@ get_ipp_attributes_async (const gchar *printer_name,
GIACallback callback,
gpointer user_data)
{
- GIAData *data;
- GThread *thread;
- GError *error = NULL;
+ GIAData *data;
+ GThread *thread;
+ g_autoptr(GError) error = NULL;
data = g_new0 (GIAData, 1);
data->printer_name = g_strdup (printer_name);
@@ -1432,7 +1411,6 @@ get_ipp_attributes_async (const gchar *printer_name,
g_warning ("%s", error->message);
callback (NULL, user_data);
- g_error_free (error);
get_ipp_attributes_data_free (data);
}
else
@@ -1497,10 +1475,10 @@ printer_set_ppd_async_dbus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- gboolean result = FALSE;
- PSPData *data = (PSPData *) user_data;
- GError *error = NULL;
+ GVariant *output;
+ gboolean result = FALSE;
+ PSPData *data = (PSPData *) user_data;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -1523,7 +1501,6 @@ printer_set_ppd_async_dbus_cb (GObject *source_object,
{
if (error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
/* Don't call callback if cancelled */
@@ -1557,9 +1534,9 @@ printer_set_ppd_async (const gchar *printer_name,
PSPCallback callback,
gpointer user_data)
{
- GDBusConnection *bus;
- PSPData *data;
- GError *error = NULL;
+ GDBusConnection *bus;
+ PSPData *data;
+ g_autoptr(GError) error = NULL;
data = g_new0 (PSPData, 1);
if (cancellable)
@@ -1578,7 +1555,6 @@ printer_set_ppd_async (const gchar *printer_name,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
goto out;
}
@@ -1616,10 +1592,10 @@ printer_set_ppd_file_async_scb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GDBusConnection *bus;
- gboolean success;
- PSPData *data = (PSPData *) user_data;
- GError *error = NULL;
+ GDBusConnection *bus;
+ gboolean success;
+ PSPData *data = (PSPData *) user_data;
+ g_autoptr(GError) error = NULL;
success = g_file_copy_finish (G_FILE (source_object),
res,
@@ -1629,7 +1605,6 @@ printer_set_ppd_file_async_scb (GObject *source_object,
if (!success)
{
g_warning ("%s", error->message);
- g_error_free (error);
goto out;
}
@@ -1637,7 +1612,6 @@ printer_set_ppd_file_async_scb (GObject *source_object,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
goto out;
}
@@ -1828,9 +1802,9 @@ get_ppds_attribute_async (gchar **ppds_names,
GPACallback callback,
gpointer user_data)
{
- GPAData *data;
- GThread *thread;
- GError *error = NULL;
+ GPAData *data;
+ GThread *thread;
+ g_autoptr(GError) error = NULL;
if (!ppds_names || !attribute_name)
{
@@ -1855,7 +1829,6 @@ get_ppds_attribute_async (gchar **ppds_names,
g_warning ("%s", error->message);
callback (NULL, user_data);
- g_error_free (error);
get_ppds_attribute_data_free (data);
}
else
@@ -1939,14 +1912,14 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- PPDName *ppd_item;
- PPDName **result = NULL;
- GPNData *data = (GPNData *) user_data;
- GError *error = NULL;
- GList *driver_list = NULL;
- GList *iter;
- gint i, j, n = 0;
+ GVariant *output;
+ PPDName *ppd_item;
+ PPDName **result = NULL;
+ GPNData *data = (GPNData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *driver_list = NULL;
+ GList *iter;
+ gint i, j, n = 0;
static const char * const match_levels[] = {
"exact-cmd",
"exact",
@@ -2022,7 +1995,6 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
{
if (error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
if (n > 0)
@@ -2073,9 +2045,9 @@ get_device_attributes_cb (gchar *device_id,
gchar *device_uri,
gpointer user_data)
{
- GDBusConnection *bus;
- GError *error = NULL;
- GPNData *data = (GPNData *) user_data;
+ GDBusConnection *bus;
+ g_autoptr(GError) error = NULL;
+ GPNData *data = (GPNData *) user_data;
if (g_cancellable_is_cancelled (data->cancellable))
goto out;
@@ -2087,7 +2059,6 @@ get_device_attributes_cb (gchar *device_id,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
goto out;
}
@@ -2181,12 +2152,12 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
gpointer user_data)
{
- GVariant *output;
- GDAData *data = (GDAData *) user_data;
- GError *error = NULL;
- GList *tmp;
- gchar *device_id = NULL;
- gchar *device_make_and_model = NULL;
+ GVariant *output;
+ GDAData *data = (GDAData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *tmp;
+ gchar *device_id = NULL;
+ gchar *device_make_and_model = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -2295,7 +2266,6 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
{
if (error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
if (!device_id || !device_make_and_model)
@@ -2380,12 +2350,12 @@ static void
get_device_attributes_async_scb (GHashTable *result,
gpointer user_data)
{
- GDBusConnection *bus;
- GVariantBuilder include_scheme_builder;
- IPPAttribute *attr;
- GDAData *data = (GDAData *) user_data;
- GError *error = NULL;
- GList *tmp;
+ GDBusConnection *bus;
+ GVariantBuilder include_scheme_builder;
+ IPPAttribute *attr;
+ GDAData *data = (GDAData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *tmp;
if (result)
{
@@ -2406,7 +2376,6 @@ get_device_attributes_async_scb (GHashTable *result,
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
goto out;
}
@@ -2890,9 +2859,9 @@ get_all_ppds_async (GCancellable *cancellable,
GAPCallback callback,
gpointer user_data)
{
- GAPData *data;
- GThread *thread;
- GError *error = NULL;
+ GAPData *data;
+ GThread *thread;
+ g_autoptr(GError) error = NULL;
data = g_new0 (GAPData, 1);
if (cancellable)
@@ -2911,7 +2880,6 @@ get_all_ppds_async (GCancellable *cancellable,
g_warning ("%s", error->message);
callback (NULL, user_data);
- g_error_free (error);
get_all_ppds_data_free (data);
}
else
@@ -3098,9 +3066,9 @@ printer_get_ppd_async (const gchar *printer_name,
PGPCallback callback,
gpointer user_data)
{
- PGPData *data;
- GThread *thread;
- GError *error = NULL;
+ PGPData *data;
+ GThread *thread;
+ g_autoptr(GError) error = NULL;
data = g_new0 (PGPData, 1);
data->printer_name = g_strdup (printer_name);
@@ -3120,7 +3088,6 @@ printer_get_ppd_async (const gchar *printer_name,
g_warning ("%s", error->message);
callback (NULL, user_data);
- g_error_free (error);
printer_get_ppd_data_free (data);
}
else
@@ -3201,9 +3168,9 @@ get_named_dest_async (const gchar *printer_name,
GNDCallback callback,
gpointer user_data)
{
- GNDData *data;
- GThread *thread;
- GError *error = NULL;
+ GNDData *data;
+ GThread *thread;
+ g_autoptr(GError) error = NULL;
data = g_new0 (GNDData, 1);
data->printer_name = g_strdup (printer_name);
@@ -3221,7 +3188,6 @@ get_named_dest_async (const gchar *printer_name,
g_warning ("%s", error->message);
callback (NULL, user_data);
- g_error_free (error);
get_named_dest_data_free (data);
}
else
@@ -3242,10 +3208,10 @@ printer_add_option_async_dbus_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GVariant *output;
- gboolean success = FALSE;
- PAOData *data = (PAOData *) user_data;
- GError *error = NULL;
+ GVariant *output;
+ gboolean success = FALSE;
+ PAOData *data = (PAOData *) user_data;
+ g_autoptr(GError) error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -3268,7 +3234,6 @@ printer_add_option_async_dbus_cb (GObject *source_object,
{
if (error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
}
if (!g_cancellable_is_cancelled (data->cancellable))
@@ -3288,17 +3253,16 @@ printer_add_option_async (const gchar *printer_name,
PAOCallback callback,
gpointer user_data)
{
- GVariantBuilder array_builder;
- GDBusConnection *bus;
- PAOData *data;
- GError *error = NULL;
- gint i;
+ GVariantBuilder array_builder;
+ GDBusConnection *bus;
+ PAOData *data;
+ g_autoptr(GError) error = NULL;
+ gint i;
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
callback (FALSE, user_data);
return;
}
@@ -3367,12 +3331,12 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
gpointer user_data)
{
- PpPrintDevice **devices = NULL;
- GVariant *output;
- GCDData *data = (GCDData *) user_data;
- GError *error = NULL;
- GList *result = NULL;
- gint num_of_devices = 0;
+ PpPrintDevice **devices = NULL;
+ GVariant *output;
+ GCDData *data = (GCDData *) user_data;
+ g_autoptr(GError) error = NULL;
+ GList *result = NULL;
+ gint num_of_devices = 0;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -3476,7 +3440,6 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("%s", error->message);
- g_error_free (error);
data->callback (result,
TRUE,
@@ -3576,17 +3539,16 @@ get_cups_devices_async (GCancellable *cancellable,
GCDCallback callback,
gpointer user_data)
{
- GDBusConnection *bus;
- GVariantBuilder include_scheme_builder;
- GCDData *data;
- GError *error = NULL;
- gchar *backend_name;
+ GDBusConnection *bus;
+ GVariantBuilder include_scheme_builder;
+ GCDData *data;
+ g_autoptr(GError) error = NULL;
+ gchar *backend_name;
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (!bus)
{
g_warning ("Failed to get system bus: %s", error->message);
- g_error_free (error);
callback (NULL, TRUE, FALSE, user_data);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]