[gnome-control-center] Simplify use of GCancellable
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] Simplify use of GCancellable
- Date: Fri, 1 Jun 2018 21:17:47 +0000 (UTC)
commit a64ef75ad7002d1c7fae302ece399caa05e9e16f
Author: Robert Ancell <robert ancell canonical com>
Date: Thu May 31 10:16:54 2018 +1200
Simplify use of GCancellable
g_cancellable_cancell can be called without checking for a NULL value.
Use g_clear_object instead of g_object_unref
panels/color/cc-color-panel.c | 3 +--
panels/network/cc-network-panel.c | 3 +--
panels/network/net-object.c | 3 +--
panels/printers/pp-details-dialog.c | 15 ++++-----------
panels/printers/pp-jobs-dialog.c | 14 ++++----------
panels/printers/pp-new-printer-dialog.c | 7 ++-----
panels/printers/pp-printer-entry.c | 22 +++++++---------------
panels/search/cc-search-locations-dialog.c | 7 ++-----
panels/search/cc-search-panel.c | 3 +--
9 files changed, 23 insertions(+), 54 deletions(-)
---
diff --git a/panels/color/cc-color-panel.c b/panels/color/cc-color-panel.c
index 1d18b3fd5..0cb9227b0 100644
--- a/panels/color/cc-color-panel.c
+++ b/panels/color/cc-color-panel.c
@@ -1954,8 +1954,7 @@ cc_color_panel_dispose (GObject *object)
g_clear_pointer (&prefs->devices, g_ptr_array_unref);
}
- if (prefs->cancellable != NULL)
- g_cancellable_cancel (prefs->cancellable);
+ g_cancellable_cancel (prefs->cancellable);
g_clear_object (&prefs->settings);
g_clear_object (&prefs->settings_colord);
g_clear_object (&prefs->cancellable);
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index c4a3b6130..4afb30895 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -210,8 +210,7 @@ cc_network_panel_dispose (GObject *object)
{
CcNetworkPanel *self = CC_NETWORK_PANEL (object);
- if (self->cancellable != NULL)
- g_cancellable_cancel (self->cancellable);
+ g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
g_clear_object (&self->client);
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
index cb96d5c05..434940cc7 100644
--- a/panels/network/net-object.c
+++ b/panels/network/net-object.c
@@ -267,8 +267,7 @@ net_object_finalize (GObject *object)
g_free (priv->id);
g_free (priv->title);
- if (priv->cancellable != NULL)
- g_object_unref (priv->cancellable);
+ g_clear_object (&priv->cancellable);
if (priv->client)
g_object_remove_weak_pointer (G_OBJECT (priv->client), (gpointer *) (&priv->client));
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index d5a56f168..7d174307b 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -462,18 +462,11 @@ pp_details_dialog_free (PpDetailsDialog *self)
self->all_ppds_list = NULL;
}
- if (self->get_all_ppds_cancellable != NULL)
- {
- g_cancellable_cancel (self->get_all_ppds_cancellable);
- g_clear_object (&self->get_all_ppds_cancellable);
- }
+ g_cancellable_cancel (self->get_all_ppds_cancellable);
+ g_clear_object (&self->get_all_ppds_cancellable);
- if (self->get_ppd_names_cancellable != NULL)
- {
- g_cancellable_cancel (self->get_ppd_names_cancellable);
- g_object_unref (self->get_ppd_names_cancellable);
- self->get_ppd_names_cancellable = NULL;
- }
+ g_cancellable_cancel (self->get_ppd_names_cancellable);
+ g_clear_object (&self->get_ppd_names_cancellable);
gtk_widget_destroy (GTK_WIDGET (self));
}
diff --git a/panels/printers/pp-jobs-dialog.c b/panels/printers/pp-jobs-dialog.c
index f1331d6d6..c5e9e9f02 100644
--- a/panels/printers/pp-jobs-dialog.c
+++ b/panels/printers/pp-jobs-dialog.c
@@ -422,11 +422,8 @@ update_jobs_list (PpJobsDialog *dialog)
if (dialog->printer_name != NULL)
{
- if (dialog->get_jobs_cancellable != NULL)
- {
- g_cancellable_cancel (dialog->get_jobs_cancellable);
- g_clear_object (&dialog->get_jobs_cancellable);
- }
+ g_cancellable_cancel (dialog->get_jobs_cancellable);
+ g_clear_object (&dialog->get_jobs_cancellable);
dialog->get_jobs_cancellable = g_cancellable_new ();
@@ -664,11 +661,8 @@ pp_jobs_dialog_set_callback (PpJobsDialog *dialog,
void
pp_jobs_dialog_free (PpJobsDialog *dialog)
{
- if (dialog->get_jobs_cancellable != NULL)
- {
- g_cancellable_cancel (dialog->get_jobs_cancellable);
- g_clear_object (&dialog->get_jobs_cancellable);
- }
+ g_cancellable_cancel (dialog->get_jobs_cancellable);
+ g_clear_object (&dialog->get_jobs_cancellable);
gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
dialog->dialog = NULL;
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index e7857fc01..0a9431055 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -1573,11 +1573,8 @@ search_for_remote_printers (THostSearchData *data)
{
PpNewPrinterDialogPrivate *priv = data->dialog->priv;
- if (priv->remote_host_cancellable != NULL)
- {
- g_cancellable_cancel (priv->remote_host_cancellable);
- g_clear_object (&priv->remote_host_cancellable);
- }
+ g_cancellable_cancel (priv->remote_host_cancellable);
+ g_clear_object (&priv->remote_host_cancellable);
priv->remote_host_cancellable = g_cancellable_new ();
diff --git a/panels/printers/pp-printer-entry.c b/panels/printers/pp-printer-entry.c
index 19ea924fc..3e5c8ff39 100644
--- a/panels/printers/pp-printer-entry.c
+++ b/panels/printers/pp-printer-entry.c
@@ -623,11 +623,8 @@ pp_printer_entry_update_jobs_count (PpPrinterEntry *self)
{
PpPrinter *printer;
- if (self->get_jobs_cancellable != NULL)
- {
- g_cancellable_cancel (self->get_jobs_cancellable);
- g_clear_object (&self->get_jobs_cancellable);
- }
+ g_cancellable_cancel (self->get_jobs_cancellable);
+ g_clear_object (&self->get_jobs_cancellable);
self->get_jobs_cancellable = g_cancellable_new ();
@@ -1009,17 +1006,12 @@ pp_printer_entry_dispose (GObject *object)
g_clear_pointer (&self->printer_make_and_model, g_free);
g_clear_pointer (&self->printer_hostname, g_free);
- if (self->get_jobs_cancellable != NULL)
- {
- g_cancellable_cancel (self->get_jobs_cancellable);
- g_clear_object (&self->get_jobs_cancellable);
- }
+ g_cancellable_cancel (self->get_jobs_cancellable);
+ g_clear_object (&self->get_jobs_cancellable);
+
+ g_cancellable_cancel (self->check_clean_heads_cancellable);
+ g_clear_object (&self->check_clean_heads_cancellable);
- if (self->check_clean_heads_cancellable)
- {
- g_cancellable_cancel (self->check_clean_heads_cancellable);
- g_clear_object (&self->check_clean_heads_cancellable);
- }
g_clear_object (&self->clean_command);
G_OBJECT_CLASS (pp_printer_entry_parent_class)->dispose (object);
diff --git a/panels/search/cc-search-locations-dialog.c b/panels/search/cc-search-locations-dialog.c
index 820de2bc7..7afbe0e02 100644
--- a/panels/search/cc-search-locations-dialog.c
+++ b/panels/search/cc-search-locations-dialog.c
@@ -75,11 +75,8 @@ cc_search_locations_dialog_init (CcSearchLocationsDialog *self)
static void
place_free (Place * p)
{
- if (p->cancellable != NULL)
- {
- g_cancellable_cancel (p->cancellable);
- g_object_unref (p->cancellable);
- }
+ g_cancellable_cancel (p->cancellable);
+ g_clear_object (&p->cancellable);
g_object_unref (p->location);
g_free (p->display_name);
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 77a6e2637..fa70770b3 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -663,8 +663,7 @@ cc_search_panel_dispose (GObject *object)
{
CcSearchPanel *self = CC_SEARCH_PANEL (object);
- if (self->load_cancellable != NULL)
- g_cancellable_cancel (self->load_cancellable);
+ g_cancellable_cancel (self->load_cancellable);
g_clear_object (&self->load_cancellable);
G_OBJECT_CLASS (cc_search_panel_parent_class)->dispose (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]