diff options
author | Jesse van den Kieboom <jessevdk@gnome.org> | 2010-04-17 16:31:40 +0200 |
---|---|---|
committer | Jesse van den Kieboom <jessevdk@gnome.org> | 2010-04-17 16:31:40 +0200 |
commit | be3fbac0630f3453d20c1365edc563348001c4e7 (patch) | |
tree | 405f4ba3681d393921c6230061dbb61a28a2284d /plugins | |
parent | adf773fc4e18c61621cb236ec5677310351654bc (diff) | |
download | gedit-be3fbac0630f3453d20c1365edc563348001c4e7.tar.gz |
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.
Diffstat (limited to 'plugins')
-rw-r--r-- | 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 861fe22cc..96b2fae93 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, |