[gnome-control-center] printers: Replace explicit g_variant_unref calls with g_autoptr
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Replace explicit g_variant_unref calls with g_autoptr
- Date: Mon, 30 Mar 2020 03:28:47 +0000 (UTC)
commit 815db8f4043824c1a898c3bf769c793a34cc913c
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Nov 21 21:52:09 2019 +1300
printers: Replace explicit g_variant_unref calls with g_autoptr
panels/printers/cc-printers-panel.c | 28 +++++++++++-----------------
panels/printers/pp-new-printer-dialog.c | 4 +---
panels/printers/pp-new-printer.c | 9 +++------
panels/printers/pp-utils.c | 12 +++---------
4 files changed, 18 insertions(+), 35 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 5d3322384..db5bc9bc8 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -136,19 +136,21 @@ execute_action (CcPrintersPanel *self,
PpPrinterEntry *printer_entry;
const gchar *action_name;
const gchar *printer_name;
- GVariant *variant;
- GVariant *action_variant;
gint count;
count = g_variant_n_children (action);
if (count == 2)
{
+ g_autoptr(GVariant) action_variant = NULL;
+
g_variant_get_child (action, 0, "v", &action_variant);
action_name = g_variant_get_string (action_variant, NULL);
/* authenticate-jobs printer-name */
if (g_strcmp0 (action_name, "authenticate-jobs") == 0)
{
+ g_autoptr(GVariant) variant = NULL;
+
g_variant_get_child (action, 1, "v", &variant);
printer_name = g_variant_get_string (variant, NULL);
@@ -157,12 +159,12 @@ execute_action (CcPrintersPanel *self,
pp_printer_entry_authenticate_jobs (printer_entry);
else
g_warning ("Could not find printer \"%s\"!", printer_name);
-
- g_variant_unref (variant);
}
/* show-jobs printer-name */
else if (g_strcmp0 (action_name, "show-jobs") == 0)
{
+ g_autoptr(GVariant) variant = NULL;
+
g_variant_get_child (action, 1, "v", &variant);
printer_name = g_variant_get_string (variant, NULL);
@@ -171,11 +173,7 @@ execute_action (CcPrintersPanel *self,
pp_printer_entry_show_jobs_dialog (printer_entry);
else
g_warning ("Could not find printer \"%s\"!", printer_name);
-
- g_variant_unref (variant);
}
-
- g_variant_unref (action_variant);
}
}
@@ -336,9 +334,7 @@ on_get_job_attributes_cb (GObject *source_object,
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
const gchar *job_originating_user_name;
const gchar *job_printer_uri;
- GVariant *attributes;
- GVariant *username;
- GVariant *printer_uri;
+ g_autoptr(GVariant) attributes = NULL;
g_autoptr(GError) error = NULL;
attributes = pp_job_get_attributes_finish (PP_JOB (source_object), res, &error);
@@ -346,8 +342,12 @@ on_get_job_attributes_cb (GObject *source_object,
if (attributes != NULL)
{
+ g_autoptr(GVariant) username = NULL;
+
if ((username = g_variant_lookup_value (attributes, "job-originating-user-name", G_VARIANT_TYPE
("as"))) != NULL)
{
+ g_autoptr(GVariant) printer_uri = NULL;
+
if ((printer_uri = g_variant_lookup_value (attributes, "job-printer-uri", G_VARIANT_TYPE ("as")))
!= NULL)
{
job_originating_user_name = g_variant_get_string (g_variant_get_child_value (username, 0),
NULL);
@@ -366,14 +366,8 @@ on_get_job_attributes_cb (GObject *source_object,
pp_printer_entry_update_jobs_count (printer_entry);
}
-
- g_variant_unref (printer_uri);
}
-
- g_variant_unref (username);
}
-
- g_variant_unref (attributes);
}
}
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index ebeba0849..71424eda7 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -907,7 +907,7 @@ group_physical_devices_dbus_cb (GObject *source_object,
if (output)
{
- GVariant *array;
+ g_autoptr(GVariant) array = NULL;
g_variant_get (output, "(@aas)", &array);
@@ -924,8 +924,6 @@ group_physical_devices_dbus_cb (GObject *source_object,
result[i] = device_uris;
i++;
}
-
- g_variant_unref (array);
}
}
else if (error &&
diff --git a/panels/printers/pp-new-printer.c b/panels/printers/pp-new-printer.c
index 4461dcfb3..0e4593feb 100644
--- a/panels/printers/pp-new-printer.c
+++ b/panels/printers/pp-new-printer.c
@@ -466,7 +466,6 @@ printer_add_real_async (PpNewPrinter *self)
static PPDName *
get_ppd_item_from_output (GVariant *output)
{
- GVariant *array;
PPDName *ppd_item = NULL;
gint j;
static const char * const match_levels[] = {
@@ -478,6 +477,8 @@ get_ppd_item_from_output (GVariant *output)
if (output)
{
+ g_autoptr(GVariant) array = NULL;
+
g_variant_get (output, "(@a(ss))", &array);
if (array)
{
@@ -507,8 +508,6 @@ get_ppd_item_from_output (GVariant *output)
}
}
}
-
- g_variant_unref (array);
}
}
@@ -1007,7 +1006,7 @@ get_missing_executables_cb (GObject *source_object,
if (output)
{
- GVariant *array;
+ g_autoptr(GVariant) array = NULL;
g_variant_get (output, "(@as)", &array);
@@ -1019,8 +1018,6 @@ get_missing_executables_cb (GObject *source_object,
g_variant_get (array, "as", &iter);
while (g_variant_iter_next (iter, "&s", &executable))
executables = g_list_append (executables, g_strdup (executable));
-
- g_variant_unref (array);
}
}
else if (error->domain == G_DBUS_ERROR &&
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 1f5f1c7de..2b56474b6 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -1905,7 +1905,7 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
if (output)
{
- GVariant *array;
+ g_autoptr(GVariant) array = NULL;
g_variant_get (output, "(@a(ss))",
&array);
@@ -1945,8 +1945,6 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
}
}
}
-
- g_variant_unref (array);
}
}
else
@@ -2125,7 +2123,7 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
if (output)
{
const gchar *ret_error;
- GVariant *devices_variant = NULL;
+ g_autoptr(GVariant) devices_variant = NULL;
g_variant_get (output, "(&s@a{ss})",
&ret_error,
@@ -2189,8 +2187,6 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
}
}
}
-
- g_variant_unref (devices_variant);
}
}
else
@@ -3263,7 +3259,7 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
if (output)
{
const gchar *ret_error;
- GVariant *devices_variant = NULL;
+ g_autoptr(GVariant) devices_variant = NULL;
gboolean is_network_device;
g_variant_get (output, "(&s@a{ss})",
@@ -3335,8 +3331,6 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
g_free (devices);
}
-
- g_variant_unref (devices_variant);
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]