[gedit/wip/spell-checking] auto-spell: fix critical message about setting tag priority
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/spell-checking] auto-spell: fix critical message about setting tag priority
- Date: Sun, 19 Jul 2015 15:07:59 +0000 (UTC)
commit 8590c085652afd320d1cc086e20211f8edf24045
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jul 19 16:56:07 2015 +0200
auto-spell: fix critical message about setting tag priority
The critical message was:
Gtk-CRITICAL **: gtk_text_tag_set_priority: assertion 'priv->table != NULL' failed
In tag_removed_cb() we need to check if the tag removed is the
tag_highlight.
Also, the doc of gtk_text_tag_set_priority() says that the tag has the
highest priority by default, just after being added to the TagTable, so
no need to set the priority in that case.
plugins/spell/gedit-automatic-spell-checker.c | 32 +++++++++++++++---------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 5b6411c..5d57e8a 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -641,8 +641,8 @@ popup_menu_cb (GtkTextView *view,
}
static void
-tag_table_changed (GtkTextTagTable *table,
- GeditAutomaticSpellChecker *spell)
+update_tag_highlight_priority (GeditAutomaticSpellChecker *spell,
+ GtkTextTagTable *table)
{
g_return_if_fail (spell->tag_highlight != NULL);
@@ -651,11 +651,22 @@ tag_table_changed (GtkTextTagTable *table,
}
static void
-tag_added_or_removed_cb (GtkTextTagTable *table,
- GtkTextTag *tag,
- GeditAutomaticSpellChecker *spell)
+tag_added_cb (GtkTextTagTable *table,
+ GtkTextTag *tag,
+ GeditAutomaticSpellChecker *spell)
{
- tag_table_changed (table, spell);
+ update_tag_highlight_priority (spell, table);
+}
+
+static void
+tag_removed_cb (GtkTextTagTable *table,
+ GtkTextTag *tag,
+ GeditAutomaticSpellChecker *spell)
+{
+ if (tag != spell->tag_highlight)
+ {
+ update_tag_highlight_priority (spell, table);
+ }
}
static void
@@ -664,7 +675,7 @@ tag_changed_cb (GtkTextTagTable *table,
gboolean size_changed,
GeditAutomaticSpellChecker *spell)
{
- tag_table_changed (table, spell);
+ update_tag_highlight_priority (spell, table);
}
static void
@@ -732,18 +743,15 @@ set_buffer (GeditAutomaticSpellChecker *spell,
tag_table = gtk_text_buffer_get_tag_table (spell->buffer);
- gtk_text_tag_set_priority (spell->tag_highlight,
- gtk_text_tag_table_get_size (tag_table) - 1);
-
g_signal_connect_object (tag_table,
"tag-added",
- G_CALLBACK (tag_added_or_removed_cb),
+ G_CALLBACK (tag_added_cb),
spell,
0);
g_signal_connect_object (tag_table,
"tag-removed",
- G_CALLBACK (tag_added_or_removed_cb),
+ G_CALLBACK (tag_removed_cb),
spell,
0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]