[gtksourceview] Use g_clear_object
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Use g_clear_object
- Date: Thu, 8 Dec 2011 14:53:38 +0000 (UTC)
commit 6142e7e9314c81c28caeff94eb3d7f39d73486e9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Dec 8 15:53:53 2011 +0100
Use g_clear_object
.../words/gtksourcecompletionwords.c | 25 ++++++-------------
.../words/gtksourcecompletionwordsbuffer.c | 3 +-
gtksourceview/gtksourcebuffer.c | 17 ++-----------
gtksourceview/gtksourcecompletion.c | 3 +-
gtksourceview/gtksourcecompletioncontext.c | 6 +----
gtksourceview/gtksourceprintcompositor.c | 5 +---
gtksourceview/gtksourcestylescheme.c | 13 +--------
gtksourceview/gtksourceview.c | 20 ++-------------
8 files changed, 20 insertions(+), 72 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index 1d580b9..ee8e579 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -308,30 +308,21 @@ gtk_source_completion_words_dispose (GObject *object)
{
GtkSourceCompletionWords *provider = GTK_SOURCE_COMPLETION_WORDS (object);
GList *cp;
-
+
population_finished (provider);
-
+
cp = g_list_copy (provider->priv->buffers);
g_list_foreach (cp, (GFunc)remove_buffer, NULL);
-
+
g_list_free (cp);
g_list_free (provider->priv->buffers);
-
+
g_free (provider->priv->name);
provider->priv->name = NULL;
-
- if (provider->priv->icon)
- {
- g_object_unref (provider->priv->icon);
- provider->priv->icon = NULL;
- }
-
- if (provider->priv->library)
- {
- g_object_unref (provider->priv->library);
- provider->priv->library = NULL;
- }
-
+
+ g_clear_object (&provider->priv->icon);
+ g_clear_object (&provider->priv->library);
+
G_OBJECT_CLASS (gtk_source_completion_words_parent_class)->dispose (object);
}
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
index 5029824..4253970 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
@@ -214,8 +214,7 @@ gtk_source_completion_words_buffer_dispose (GObject *object)
g_signal_handler_disconnect (buffer->priv->library,
buffer->priv->unlock_handler_id);
- g_object_unref (buffer->priv->library);
- buffer->priv->library = NULL;
+ g_clear_object (&buffer->priv->library);
}
G_OBJECT_CLASS (gtk_source_completion_words_buffer_parent_class)->dispose (object);
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index b5260a5..00babe5 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -484,7 +484,6 @@ gtk_source_buffer_dispose (GObject *object)
g_return_if_fail (GTK_SOURCE_IS_BUFFER (object));
buffer = GTK_SOURCE_BUFFER (object);
- g_return_if_fail (buffer->priv != NULL);
if (buffer->priv->undo_manager != NULL)
{
@@ -494,21 +493,11 @@ gtk_source_buffer_dispose (GObject *object)
if (buffer->priv->highlight_engine != NULL)
{
_gtk_source_engine_attach_buffer (buffer->priv->highlight_engine, NULL);
- g_object_unref (buffer->priv->highlight_engine);
- buffer->priv->highlight_engine = NULL;
}
- if (buffer->priv->language != NULL)
- {
- g_object_unref (buffer->priv->language);
- buffer->priv->language = NULL;
- }
-
- if (buffer->priv->style_scheme != NULL)
- {
- g_object_unref (buffer->priv->style_scheme);
- buffer->priv->style_scheme = NULL;
- }
+ g_clear_object (&buffer->priv->highlight_engine);
+ g_clear_object (&buffer->priv->language);
+ g_clear_object (&buffer->priv->style_scheme);
G_OBJECT_CLASS (gtk_source_buffer_parent_class)->dispose (object);
}
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 5bdb34a..3214085 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1925,9 +1925,8 @@ gtk_source_completion_dispose (GObject *object)
if (completion->priv->view != NULL)
{
disconnect_view (completion);
- g_object_unref (completion->priv->view);
- completion->priv->view = NULL;
+ g_clear_object (&completion->priv->view);
g_list_foreach (completion->priv->providers, (GFunc)g_object_unref, NULL);
}
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index 38b96cc..3e0e47f 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -86,11 +86,7 @@ gtk_source_completion_context_dispose (GObject *object)
context->priv->mark_set_id = 0;
}
- if (context->priv->completion)
- {
- g_object_unref (context->priv->completion);
- context->priv->completion = NULL;
- }
+ g_clear_object (&context->priv->completion);
if (context->priv->mark)
{
diff --git a/gtksourceview/gtksourceprintcompositor.c b/gtksourceview/gtksourceprintcompositor.c
index 3c65601..1f0e1f3 100644
--- a/gtksourceview/gtksourceprintcompositor.c
+++ b/gtksourceview/gtksourceprintcompositor.c
@@ -412,10 +412,7 @@ gtk_source_print_compositor_dispose (GObject *object)
compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
- if (compositor->priv->buffer != NULL) {
- g_object_unref (compositor->priv->buffer);
- compositor->priv->buffer = NULL;
- }
+ g_clear_object (&compositor->priv->buffer);
G_OBJECT_CLASS (gtk_source_print_compositor_parent_class)->dispose (object);
}
diff --git a/gtksourceview/gtksourcestylescheme.c b/gtksourceview/gtksourcestylescheme.c
index 91340a2..5ab0853 100644
--- a/gtksourceview/gtksourcestylescheme.c
+++ b/gtksourceview/gtksourcestylescheme.c
@@ -109,17 +109,8 @@ gtk_source_style_scheme_dispose (GObject *object)
scheme->priv->defined_styles = NULL;
}
- if (scheme->priv->parent != NULL)
- {
- g_object_unref (scheme->priv->parent);
- scheme->priv->parent = NULL;
- }
-
- if (scheme->priv->css != NULL)
- {
- g_object_unref (scheme->priv->css);
- scheme->priv->css = NULL;
- }
+ g_clear_object (&scheme->priv->parent);
+ g_clear_object (&scheme->priv->css);
G_OBJECT_CLASS (gtk_source_style_scheme_parent_class)->dispose (object);
}
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index e8406c8..4107745 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -1038,23 +1038,9 @@ gtk_source_view_dispose (GObject *object)
}
set_source_buffer (view, NULL);
- if (view->priv->completion != NULL)
- {
- g_object_unref (view->priv->completion);
- view->priv->completion = NULL;
- }
-
- if (view->priv->left_gutter)
- {
- g_object_unref (view->priv->left_gutter);
- view->priv->left_gutter = NULL;
- }
-
- if (view->priv->right_gutter)
- {
- g_object_unref (view->priv->right_gutter);
- view->priv->right_gutter = NULL;
- }
+ g_clear_object (&view->priv->completion);
+ g_clear_object (&view->priv->left_gutter);
+ g_clear_object (&view->priv->right_gutter);
view->priv->dispose_has_run = 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]