[gnome-control-center] printers: Simplify freeing of lists of found printers
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Simplify freeing of lists of found printers
- Date: Tue, 3 Sep 2013 20:11:58 +0000 (UTC)
commit 03d463379f85f30505665b074fa844da67adefb8
Author: Marek Kasik <mkasik redhat com>
Date: Tue Sep 3 18:14:30 2013 +0200
printers: Simplify freeing of lists of found printers
Create a dedicated function for freeing of PpDevicesList.
https://bugzilla.gnome.org/show_bug.cgi?id=698532
panels/printers/pp-new-printer-dialog.c | 38 ++++++++++++++----------------
1 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index e183ff4..04783db 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -621,6 +621,20 @@ t_device_copy (TDevice *device)
}
static void
+pp_devices_list_free (PpDevicesList *result)
+{
+ GList *iter;
+
+ if (result)
+ {
+ for (iter = result->devices; iter; iter = iter->next)
+ pp_print_device_free ((PpPrintDevice *) iter->data);
+ g_list_free (result->devices);
+ g_free (result);
+ }
+}
+
+static void
update_spinner_state (PpNewPrinterDialog *dialog)
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
@@ -968,7 +982,6 @@ get_snmp_devices_cb (GObject *source_object,
PpHost *host = (PpHost *) source_object;
GError *error = NULL;
PpDevicesList *result;
- GList *iter;
result = pp_host_get_snmp_devices_finish (host, res, &error);
g_object_unref (source_object);
@@ -990,10 +1003,7 @@ get_snmp_devices_cb (GObject *source_object,
actualize_devices_list (dialog);
- for (iter = result->devices; iter; iter = iter->next)
- pp_print_device_free ((PpPrintDevice *) iter->data);
- g_list_free (result->devices);
- g_free (result);
+ pp_devices_list_free (result);
}
else
{
@@ -1023,7 +1033,6 @@ get_remote_cups_devices_cb (GObject *source_object,
PpHost *host = (PpHost *) source_object;
GError *error = NULL;
PpDevicesList *result;
- GList *iter;
result = pp_host_get_remote_cups_devices_finish (host, res, &error);
g_object_unref (source_object);
@@ -1045,10 +1054,7 @@ get_remote_cups_devices_cb (GObject *source_object,
actualize_devices_list (dialog);
- for (iter = result->devices; iter; iter = iter->next)
- pp_print_device_free ((PpPrintDevice *) iter->data);
- g_list_free (result->devices);
- g_free (result);
+ pp_devices_list_free (result);
}
else
{
@@ -1078,7 +1084,6 @@ get_samba_host_devices_cb (GObject *source_object,
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
GError *error = NULL;
- GList *iter;
result = pp_samba_get_devices_finish (samba, res, &error);
g_object_unref (source_object);
@@ -1100,10 +1105,7 @@ get_samba_host_devices_cb (GObject *source_object,
actualize_devices_list (dialog);
- for (iter = result->devices; iter; iter = iter->next)
- pp_print_device_free ((PpPrintDevice *) iter->data);
- g_list_free (result->devices);
- g_free (result);
+ pp_devices_list_free (result);
}
else
{
@@ -1133,7 +1135,6 @@ get_samba_devices_cb (GObject *source_object,
PpDevicesList *result;
PpSamba *samba = (PpSamba *) source_object;
GError *error = NULL;
- GList *iter;
result = pp_samba_get_devices_finish (samba, res, &error);
g_object_unref (source_object);
@@ -1155,10 +1156,7 @@ get_samba_devices_cb (GObject *source_object,
actualize_devices_list (dialog);
- for (iter = result->devices; iter; iter = iter->next)
- pp_print_device_free ((PpPrintDevice *) iter->data);
- g_list_free (result->devices);
- g_free (result);
+ pp_devices_list_free (result);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]