[gaim-migrate @ 13522]

Sat, 20 Aug 2005 21:11:57 +0000

author
Stu Tomlinson <nosnilmot@pidgin.im>
date
Sat, 20 Aug 2005 21:11:57 +0000
changeset 11319
2cd41946506d
parent 11318
13fa1d5134f3
child 11320
1b2fd0a486aa

[gaim-migrate @ 13522]
I'm quite amazed this worked at all. Did no-one notice debug output like this:

Gtk: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators
Gtk: gtk_text_buffer_set_mark: assertion `gtk_text_iter_get_buffer (iter) == buffer' failed

plugins/spellchk.c file | annotate | diff | comparison | revisions
--- a/plugins/spellchk.c	Sat Aug 20 20:17:08 2005 +0000
+++ b/plugins/spellchk.c	Sat Aug 20 21:11:57 2005 +0000
@@ -461,7 +461,8 @@
 insert_text_after(GtkTextBuffer *buffer, GtkTextIter *iter,
 					gchar *text, gint len, spellchk *spell)
 {
-	GtkTextIter start;
+	GtkTextIter start, end;
+	GtkTextMark *mark;
 
 	if (spell->ignore_correction) {
 		spell->ignore_correction = FALSE;
@@ -474,7 +475,10 @@
 	if (len == 1)
 	  check_range(spell, buffer, start, *iter);
 
-	gtk_text_buffer_move_mark(buffer, spell->mark_insert_end, iter);
+	/* if check_range modified the buffer, iter has been invalidated */
+	mark = gtk_text_buffer_get_insert(buffer);
+	gtk_text_buffer_get_iter_at_mark(buffer, &end, mark);
+	gtk_text_buffer_move_mark(buffer, spell->mark_insert_end, &end);
 
 	spell->inserting = FALSE;
 

mercurial