Hello,
I'm fairly new to Gtk+ programming and was happy to find this active forum this evening. I've been struggling with isolating and understanding an error I'm getting when I attempt to use the iterators assigned when calling the gtk_text_iter_forward_search() function. I don't receive an error when I call the function and I'm able to use the start and end iterators assigned by the function earlier in my program. However, when I come to the following block of code, something seems to invalidate the iterators. When I try to call them, for instance to get text between the start and end iterators, I get this error message:
(GtkScratch:5907): Gtk-CRITICAL **: _gtk_text_btree_get_text: assertion `_gtk_text_iter_get_btree (start_orig) == _gtk_text_iter_get_btree (end_orig)' failed
I don't really understand the error message. I'm not doing anything which causes change to the buffer, which is the most obvious thing I could think that would cause an error. I'm fairly certain the error is in the following code snippet. I've tested the same functions just before this block and everything works just before this.
Code:
gchar* start_tag_string;
gchar* end_tag_string;
start_tag_string = malloc((tagLength+1)*sizeof(gchar));
end_tag_string = malloc((tagLength+2)*sizeof(gchar));
strcpy(start_tag_string,next->data);
end_tag_string[0] = '<';
end_tag_string[1] = '/';
gint i = 0;
for(i; i <= tagLength; i++)
{end_tag_string[i+2] = start_tag_string[i+1];}
///Try to match end tag.
if(gtk_text_iter_forward_search (&end_of_start_tag,
end_tag_string,
0,
&start_of_end_tag,
&end_of_end_tag,
&endIter));
{
tmpText = gtk_text_iter_get_text(&start_of_end_tag, &end_of_end_tag); //this causes the error
printf(tmpText);