[giggle] Use g_clear_object to clear references
- From: Javier JardÃn <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giggle] Use g_clear_object to clear references
- Date: Wed, 21 Dec 2011 03:02:07 +0000 (UTC)
commit 4f228bfe5995318727ce91774686db579e7dad86
Author: Javier JardÃn <jjardon gnome org>
Date: Sun Dec 4 20:47:36 2011 +0000
Use g_clear_object to clear references
libgiggle/giggle-ref.c | 10 +++-------
libgiggle/giggle-revision.c | 12 ++++--------
src/giggle-remotes-view.c | 11 ++---------
src/giggle-rev-list-view.c | 40 ++++++++++------------------------------
src/giggle-view-history.c | 12 ++++--------
src/giggle-window.c | 25 +++++--------------------
6 files changed, 28 insertions(+), 82 deletions(-)
---
diff --git a/libgiggle/giggle-ref.c b/libgiggle/giggle-ref.c
index 4f9087d..4a6018e 100644
--- a/libgiggle/giggle-ref.c
+++ b/libgiggle/giggle-ref.c
@@ -104,10 +104,8 @@ giggle_ref_finalize (GObject *object)
g_free (priv->name);
g_free (priv->sha);
- if (priv->revision) {
- g_object_unref (priv->revision);
- }
-
+ g_clear_object (&priv->revision);
+
G_OBJECT_CLASS (giggle_ref_parent_class)->finalize (object);
}
@@ -157,9 +155,7 @@ giggle_ref_set_property (GObject *object,
priv->sha = g_value_dup_string (value);
break;
case PROP_HEAD:
- if (priv->revision) {
- g_object_unref (priv->revision);
- }
+ g_clear_object (&priv->revision);
priv->revision = GIGGLE_REVISION (g_value_dup_object (value));
break;
default:
diff --git a/libgiggle/giggle-revision.c b/libgiggle/giggle-revision.c
index 0fcdf4c..d622a34 100644
--- a/libgiggle/giggle-revision.c
+++ b/libgiggle/giggle-revision.c
@@ -139,10 +139,8 @@ revision_finalize (GObject *object)
g_free (priv->sha);
g_free (priv->short_log);
- if (priv->author)
- g_object_unref (priv->author);
- if (priv->committer)
- g_object_unref (priv->committer);
+ g_clear_object (&priv->author);
+ g_clear_object (&priv->committer);
if (priv->date)
g_free (priv->date);
@@ -252,8 +250,7 @@ giggle_revision_set_author (GiggleRevision *revision,
g_return_if_fail (GIGGLE_IS_REVISION (revision));
g_return_if_fail (GIGGLE_IS_AUTHOR (author) | !author);
- if (revision->priv->author)
- g_object_unref (revision->priv->author);
+ g_clear_object (&revision->priv->author)
revision->priv->author = g_object_ref (author);
}
@@ -272,8 +269,7 @@ giggle_revision_set_committer (GiggleRevision *revision,
g_return_if_fail (GIGGLE_IS_REVISION (revision));
g_return_if_fail (GIGGLE_IS_AUTHOR (committer) | !committer);
- if (revision->priv->committer)
- g_object_unref (revision->priv->committer);
+ g_clear_object (&revision->priv->committer);
revision->priv->committer = g_object_ref (committer);
}
diff --git a/src/giggle-remotes-view.c b/src/giggle-remotes-view.c
index acf239b..d891a9a 100644
--- a/src/giggle-remotes-view.c
+++ b/src/giggle-remotes-view.c
@@ -50,15 +50,8 @@ remotes_view_dispose (GObject *object)
priv = GET_PRIV (object);
- if (priv->git) {
- g_object_unref (priv->git);
- priv->git = NULL;
- }
-
- if (priv->store) {
- g_object_unref (priv->store);
- priv->store = NULL;
- }
+ g_clear_object (&priv->git);
+ g_clear_object (&priv->store);
G_OBJECT_CLASS (giggle_remotes_view_parent_class)->dispose (object);
}
diff --git a/src/giggle-rev-list-view.c b/src/giggle-rev-list-view.c
index 8ccae33..9800f3d 100644
--- a/src/giggle-rev-list-view.c
+++ b/src/giggle-rev-list-view.c
@@ -120,20 +120,9 @@ G_DEFINE_TYPE_WITH_CODE (GiggleRevListView, giggle_rev_list_view, GTK_TYPE_TREE_
static void
rev_list_view_reset_emblems (GiggleRevListViewPriv *priv)
{
- if (priv->emblem_branch) {
- g_object_unref (priv->emblem_branch);
- priv->emblem_branch = NULL;
- }
-
- if (priv->emblem_remote) {
- g_object_unref (priv->emblem_remote);
- priv->emblem_remote = NULL;
- }
-
- if (priv->emblem_tag) {
- g_object_unref (priv->emblem_tag);
- priv->emblem_tag = NULL;
- }
+ g_clear_object (&priv->emblem_branch);
+ g_clear_object (&priv->emblem_remote);
+ g_clear_object (&priv->emblem_tag);
}
static void
@@ -151,10 +140,7 @@ rev_list_view_dispose (GObject *object)
priv->job = NULL;
}
- if (priv->git) {
- g_object_unref (priv->git);
- priv->git = NULL;
- }
+ g_clear_object (&priv->git);
if (priv->main_loop) {
if (g_main_loop_is_running (priv->main_loop))
@@ -219,8 +205,7 @@ modify_ref_cb (GiggleGit *git,
g_object_notify (G_OBJECT (priv->git), "git-dir");
}
- g_object_unref (priv->job);
- priv->job = NULL;
+ g_clear_object (&priv->job);
}
static void
@@ -723,8 +708,7 @@ log_matches_cb (GiggleGit *git,
g_free (casefold_log);
}
- g_object_unref (priv->job);
- priv->job = NULL;
+ g_clear_object (&priv->job);
g_main_loop_quit (data->main_loop);
}
@@ -791,8 +775,7 @@ diff_matches_cb (GiggleGit *git,
data->match = (strstr (diff_str, data->search_term) != NULL);
}
- g_object_unref (priv->job);
- priv->job = NULL;
+ g_clear_object (&priv->job);
g_main_loop_quit (data->main_loop);
}
@@ -1278,9 +1261,8 @@ rev_list_view_create_patch_callback (GiggleGit *git,
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
-
- g_object_unref (priv->job);
- priv->job = NULL;
+
+ g_clear_object (&priv->job);
}
static void
@@ -1352,9 +1334,7 @@ rev_list_view_create_patch (GtkAction *action,
rev_list_view_create_patch_callback,
list);
- if (revision) {
- g_object_unref (revision);
- }
+ g_clear_object (&revision);
}
static void
diff --git a/src/giggle-view-history.c b/src/giggle-view-history.c
index ea27e63..2cc8b48 100644
--- a/src/giggle-view-history.c
+++ b/src/giggle-view-history.c
@@ -168,8 +168,8 @@ view_history_finalize (GObject *object)
priv->diff_current_job = NULL;
}
- g_object_unref (priv->configuration);
- g_object_unref (priv->git);
+ g_clear_object (&priv->configuration);
+ g_clear_object (&priv->git);
G_OBJECT_CLASS (giggle_view_history_parent_class)->finalize (object);
}
@@ -282,8 +282,7 @@ view_history_get_branches_cb (GiggleGit *git,
}
}
- g_object_unref (priv->job);
- priv->job = NULL;
+ g_clear_object (&priv->job);
}
static void
@@ -736,10 +735,7 @@ view_history_snapshot_dispose (GObject *object)
snapshot->cursor_row = NULL;
}
- if (snapshot->cursor_column) {
- g_object_unref (snapshot->cursor_column);
- snapshot->cursor_column = NULL;
- }
+ g_clear_object (&snapshot->cursor_column);
G_OBJECT_CLASS (giggle_view_history_snapshot_parent_class)->dispose (object);
}
diff --git a/src/giggle-window.c b/src/giggle-window.c
index 4d7a73f..7421827 100644
--- a/src/giggle-window.c
+++ b/src/giggle-window.c
@@ -269,15 +269,9 @@ window_dispose (GObject *object)
priv->personal_details_window = NULL;
}
- if (priv->git) {
- g_object_unref (priv->git);
- priv->git = NULL;
- }
+ g_clear_object (&priv->git);
- if (priv->recent_manager) {
- g_object_unref (priv->recent_manager);
- priv->recent_manager = NULL;
- }
+ g_clear_object (&priv->recent_manager);
if (priv->recent_action_group) {
gtk_ui_manager_remove_action_group (priv->ui_manager,
@@ -285,20 +279,11 @@ window_dispose (GObject *object)
priv->recent_action_group = NULL;
}
- if (priv->ui_manager) {
- g_object_unref (priv->ui_manager);
- priv->ui_manager = NULL;
- }
+ g_clear_object (&priv->ui_manager);
- if (priv->configuration) {
- g_object_unref (priv->configuration);
- priv->configuration = NULL;
- }
+ g_clear_object (&priv->configuration);
- if (priv->plugin_manager) {
- g_object_unref (priv->plugin_manager);
- priv->plugin_manager = NULL;
- }
+ g_clear_object (&priv->plugin_manager);
G_OBJECT_CLASS (giggle_window_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]