Re: Changing GtkTextTags?



Joe Shaw <joe ximian com> writes:
> Is it possible to change the attributes of a GtkTextTag? When I try to
> use g_object_set() on a tag, I get the following warnings:
> 
> Gtk-CRITICAL **: file gtktextbtree.c: line 3581
> (_gtk_text_line_byte_locate): assertion `byte_offset >= 0' failed
> 
> Gtk-ERROR **: Byte index -1 is off the end of the line
> 
> The former warning is because the byte_offset being passed in is -1. The
> byte_offset is passed in pretty straight from
> _gtk_text_btree_get_iter_at_last_toggle(), which calls line =
> _gtk_text_btree_last_could_contain_tag (tree, tag). If line is NULL, it
> passes 0 as the byte offset. If not (as it is in my case), it passes -1.
> The second error is caused by much the same thing. The code path is
> pretty straightforward, so I figure I either can't set it or it's a bug.
> 

gtk-demo and testtext have a zillion g_object_set() on GtkTextTag (or
tag_create() anyway which is just a convenience wrapper around same).

So you're just triggering this bug somehow. Bug is just that
iter_init_from_byte_offset() does not allow -1 as an arg, yet it's
being passed in.

I believe the easiest fix is:

 iter_init_from_byte_offset (iter, tree, line, 0);
 gtk_text_iter_forward_to_line_end (&iter);
 gtk_text_iter_backward_to_tag_toggle (iter, tag);                            

Could speed this up by poking in the btree, but this way is easy to
implement and speed probably doesn't matter.

Havoc







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