On Sun, 10 Jun 2001, Skip Montanaro wrote:

>
> The following simple script generates an assertion error at line 1721 of
> gtktextiter.c (the environment is Mandrake 8.0, Python 2.1.1a1, Gtk 1.3.5,
> and a slightly modifed version of the 20010408 PyGtk snapshot - not modified
> in any of the TextView/TextBuffer areas I don't think):
>
>     import gtk
>
>     def focusin(*args):
>       buf = tview.get_buffer()
>       start = buf.get_iter_at_offset(buf.get_char_count())
>       buf.insert(start, "focus_in")
>       end = buf.get_iter_at_offset(buf.get_char_count())
>       tag = buf.create_tag("help")
>       buf.apply_tag(tag, start, end)
>
>     window = gtk.GtkWindow()
>     tview = gtk.GtkTextView()
>     tview.connect("focus_in_event", focusin)
>     window.add(tview)
>     window.show_all()
>     gtk.mainloop()
>
> If I examine the relevant values in frame 4 where the assertion fails, I
> find that new_line is NULL and that real->line_char_offset and
> real->line_byte_offset are both 1.  If I comment out the last two lines of
> focusin, I get no errors, but the string "focus_in" isn't visible through
> the TextView widget either.  In a version of this script that was supposed
> to be a more-or-less actual script, new_line had the value 0xffffff (even
> though the if test that landed execution at line 1711 failed), which led
> Havoc to suggest that the stack was getting trashed.

This would appear to be caused by the extra '\n' in the text buffer.  By
changing occurences of buf.get_char_count() with buf.get_char_count()-1
things work as expected (although the text doesn't show up until I try to
select it -- this seems to be a redraw related problem).

>
> Before I file a Gtk bug report, can someone tell if I'm doing something
> obviously wrong or reproduce the error I'm seeing?
>

I could reproduce this bug with CVS gtk+ as of a few days ago.  I am
guessing that it is caused by not having a '\n' at the end of the buffer,
as I said above.  You may as well file this as a bug against gtk+
(remember to set the milestone to 2.0 after submitting), as your code
looks like an `obvious' way of doing things so others may be tripped up by
it.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to