[gedit] Fix warnings on tag not being a GtkTextTag when removing autospell



commit be3fbac0630f3453d20c1365edc563348001c4e7
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sat Apr 17 16:31:40 2010 +0200

    Fix warnings on tag not being a GtkTextTag when removing autospell
    
    The problem occurred because the tag table is emptied before the
    destroy function runs. This patch simply adds a weak reference to the
    tag object to be notified if it's destroyed before the finalize of the
    spell object runs.

 plugins/spell/gedit-automatic-spell-checker.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 861fe22..96b2fae 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -699,6 +699,13 @@ highlight_updated (GtkSourceBuffer            *buffer,
 	check_range (spell, *start, *end, FALSE);
 }
 
+static void
+spell_tag_destroyed (GeditAutomaticSpellChecker *spell,
+                     GObject                    *where_the_object_was)
+{
+	spell->tag_highlight = NULL;
+}
+
 GeditAutomaticSpellChecker *
 gedit_automatic_spell_checker_new (GeditDocument     *doc,
 				   GeditSpellChecker *checker)
@@ -778,6 +785,10 @@ gedit_automatic_spell_checker_new (GeditDocument     *doc,
 				"underline", PANGO_UNDERLINE_ERROR,
 				NULL);
 
+	g_object_weak_ref (G_OBJECT (spell->tag_highlight),
+	                   (GWeakNotify)spell_tag_destroyed,
+	                   spell);
+
 	tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (doc));
 
 	gtk_text_tag_set_priority (spell->tag_highlight, 
@@ -893,7 +904,7 @@ gedit_automatic_spell_checker_free_internal (GeditAutomaticSpellChecker *spell)
 
 	table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (spell->doc));
 
-	if (table != NULL)
+	if (table != NULL && spell->tag_highlight != NULL)
 	{
 		gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), 
 					    &start, 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]