[gnome-settings-daemon] housekeeping: Simplify cleanup code
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] housekeeping: Simplify cleanup code
- Date: Thu, 18 Jul 2013 14:57:00 +0000 (UTC)
commit ccfcd889820629a9a9eea7029fd9615cfe490289
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jul 18 16:55:56 2013 +0200
housekeeping: Simplify cleanup code
Using g_clear_{pointer,object} as appropriate.
plugins/housekeeping/gsd-disk-space.c | 34 +++++------------------
plugins/housekeeping/gsd-housekeeping-manager.c | 21 +++-----------
plugins/housekeeping/gsd-ldsm-dialog.c | 11 +++-----
3 files changed, 15 insertions(+), 51 deletions(-)
---
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index 815012d..93703eb 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -1037,33 +1037,13 @@ gsd_ldsm_clean (void)
g_source_remove (ldsm_timeout_id);
ldsm_timeout_id = 0;
- if (ldsm_notified_hash)
- g_hash_table_destroy (ldsm_notified_hash);
- ldsm_notified_hash = NULL;
-
- if (ldsm_monitor)
- g_object_unref (ldsm_monitor);
- ldsm_monitor = NULL;
-
- if (settings != NULL) {
- g_object_unref (settings);
- }
-
+ g_clear_pointer (&ldsm_notified_hash, g_hash_table_destroy);
+ g_clear_object (&ldsm_monitor);
+ g_clear_object (&settings);
g_clear_object (&privacy_settings);
-
- if (dialog) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- dialog = NULL;
- }
-
- if (notification != NULL) {
- notify_notification_close (notification, NULL);
- notification = NULL;
- }
-
- if (ignore_paths) {
- g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
- g_slist_free (ignore_paths);
- }
+ g_clear_object (&dialog);
+ g_clear_pointer (¬ification, notify_notification_close);
+ g_slist_free_full (ignore_paths, g_free);
+ ignore_paths = NULL;
}
diff --git a/plugins/housekeeping/gsd-housekeeping-manager.c b/plugins/housekeeping/gsd-housekeeping-manager.c
index f51d520..96ec90d 100644
--- a/plugins/housekeeping/gsd-housekeeping-manager.c
+++ b/plugins/housekeeping/gsd-housekeeping-manager.c
@@ -412,21 +412,9 @@ gsd_housekeeping_manager_stop (GsdHousekeepingManager *manager)
g_debug ("Stopping housekeeping manager");
- if (manager->priv->bus_cancellable != NULL) {
- g_cancellable_cancel (manager->priv->bus_cancellable);
- g_object_unref (manager->priv->bus_cancellable);
- manager->priv->bus_cancellable = NULL;
- }
-
- if (manager->priv->introspection_data) {
- g_dbus_node_info_unref (manager->priv->introspection_data);
- manager->priv->introspection_data = NULL;
- }
-
- if (manager->priv->connection != NULL) {
- g_object_unref (manager->priv->connection);
- manager->priv->connection = NULL;
- }
+ g_clear_object (&p->bus_cancellable);
+ g_clear_pointer (&p->introspection_data, g_dbus_node_info_unref);
+ g_clear_object (&p->connection);
if (p->short_term_cb) {
g_source_remove (p->short_term_cb);
@@ -444,10 +432,9 @@ gsd_housekeeping_manager_stop (GsdHousekeepingManager *manager)
do_cleanup (manager);
}
- g_object_unref (p->settings);
- p->settings = NULL;
}
+ g_clear_object (&p->settings);
gsd_ldsm_clean ();
}
diff --git a/plugins/housekeeping/gsd-ldsm-dialog.c b/plugins/housekeeping/gsd-ldsm-dialog.c
index 3a96f15..8b38118 100644
--- a/plugins/housekeeping/gsd-ldsm-dialog.c
+++ b/plugins/housekeeping/gsd-ldsm-dialog.c
@@ -267,13 +267,10 @@ gsd_ldsm_dialog_finalize (GObject *object)
g_return_if_fail (GSD_IS_LDSM_DIALOG (object));
self = GSD_LDSM_DIALOG (object);
-
- if (self->priv->partition_name)
- g_free (self->priv->partition_name);
-
- if (self->priv->mount_path)
- g_free (self->priv->mount_path);
-
+
+ g_clear_pointer (&self->priv->partition_name, g_free);
+ g_clear_pointer (&self->priv->mount_path, g_free);
+
G_OBJECT_CLASS (gsd_ldsm_dialog_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]