[gnome-control-center] printers: Don't pass PpHost references around
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Don't pass PpHost references around
- Date: Tue, 22 Sep 2020 21:30:36 +0000 (UTC)
commit 519c390b042d07d072656a6896ad9db536d068e7
Author: Robert Ancell <robert ancell canonical com>
Date: Sat Jun 27 10:28:20 2020 +1200
printers: Don't pass PpHost references around
An internal GTask will hold a reference to it for the duration of the async calls.
Correctly unref these objects in finalize.
panels/printers/pp-new-printer-dialog.c | 44 ++++++++++++---------------------
1 file changed, 16 insertions(+), 28 deletions(-)
---
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index e17e36ce5..3d29b5dc7 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -542,6 +542,10 @@ pp_new_printer_dialog_finalize (GObject *object)
g_clear_object (&self->local_printer_icon);
g_clear_object (&self->remote_printer_icon);
g_clear_object (&self->authenticated_server_icon);
+ g_clear_object (&self->snmp_host);
+ g_clear_object (&self->socket_host);
+ g_clear_object (&self->lpd_host);
+ g_clear_object (&self->remote_cups_host);
g_clear_object (&self->samba_host);
if (self->num_of_dests > 0)
@@ -1055,17 +1059,14 @@ get_snmp_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *self = user_data;
- PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) devices = NULL;
- devices = pp_host_get_snmp_devices_finish (host, res, &error);
- g_object_unref (source_object);
+ devices = pp_host_get_snmp_devices_finish (PP_HOST (source_object), res, &error);
if (devices != NULL)
{
- if ((gpointer) source_object == (gpointer) self->snmp_host)
- self->snmp_host = NULL;
+ g_clear_object(&self->snmp_host);
add_devices_to_list (self, devices);
@@ -1077,8 +1078,7 @@ get_snmp_devices_cb (GObject *source_object,
{
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) self->snmp_host)
- self->snmp_host = NULL;
+ g_clear_object(&self->snmp_host);
update_dialog_state (self);
}
@@ -1091,17 +1091,14 @@ get_remote_cups_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *self = user_data;
- PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) devices = NULL;
- devices = pp_host_get_remote_cups_devices_finish (host, res, &error);
- g_object_unref (source_object);
+ devices = pp_host_get_remote_cups_devices_finish (PP_HOST (source_object), res, &error);
if (devices != NULL)
{
- if ((gpointer) source_object == (gpointer) self->remote_cups_host)
- self->remote_cups_host = NULL;
+ g_clear_object(&self->remote_cups_host);
add_devices_to_list (self, devices);
@@ -1113,8 +1110,7 @@ get_remote_cups_devices_cb (GObject *source_object,
{
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) self->remote_cups_host)
- self->remote_cups_host = NULL;
+ g_clear_object(&self->remote_cups_host);
update_dialog_state (self);
}
@@ -1191,17 +1187,14 @@ get_jetdirect_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *self = user_data;
- PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) devices = NULL;
- devices = pp_host_get_jetdirect_devices_finish (host, res, &error);
- g_object_unref (source_object);
+ devices = pp_host_get_jetdirect_devices_finish (PP_HOST (source_object), res, &error);
if (devices != NULL)
{
- if ((gpointer) source_object == (gpointer) self->socket_host)
- self->socket_host = NULL;
+ g_clear_object(&self->socket_host);
add_devices_to_list (self, devices);
@@ -1213,8 +1206,7 @@ get_jetdirect_devices_cb (GObject *source_object,
{
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) self->socket_host)
- self->socket_host = NULL;
+ g_clear_object(&self->socket_host);
update_dialog_state (self);
}
@@ -1227,17 +1219,14 @@ get_lpd_devices_cb (GObject *source_object,
gpointer user_data)
{
PpNewPrinterDialog *self = user_data;
- PpHost *host = (PpHost *) source_object;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) devices = NULL;
- devices = pp_host_get_lpd_devices_finish (host, res, &error);
- g_object_unref (source_object);
+ devices = pp_host_get_lpd_devices_finish (PP_HOST (source_object), res, &error);
if (devices != NULL)
{
- if ((gpointer) source_object == (gpointer) self->lpd_host)
- self->lpd_host = NULL;
+ g_clear_object(&self->lpd_host);
add_devices_to_list (self, devices);
@@ -1249,8 +1238,7 @@ get_lpd_devices_cb (GObject *source_object,
{
g_warning ("%s", error->message);
- if ((gpointer) source_object == (gpointer) self->lpd_host)
- self->lpd_host = NULL;
+ g_clear_object(&self->lpd_host);
update_dialog_state (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]