GNOME Bugzilla – Bug 65731
GtkTextView with custom GtkTextBuffer dies after hitting 'Del' or 'BS'.
Last modified: 2004-12-22 21:47:04 UTC
Test case: #include <gtk/gtk.h> int main (int argc, char** argv) { GtkWidget *view; GtkWidget *window; GtkTextBuffer* buffer; gtk_init (&argc, &argv); view = gtk_text_view_new (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); */ /* gtk_text_buffer_set_text (buffer, "0123456789\0", -1); */ buffer = gtk_text_buffer_new (NULL); gtk_text_buffer_set_text (buffer, "0123456789\0", -1); gtk_text_view_set_buffer (GTK_TEXT_VIEW(view), buffer); gtk_container_add (GTK_CONTAINER (window), view); gtk_widget_show_all (window); gtk_main(); } How to reproduce. 1. Compile and run the program. 2. Set the corsor to any position except start and end positions. 3. Press 'Delete' or 'Backspace' button. The program dies producing this output: 1 lines in tree 0x8064190 0| line: 0x8063f58 parent: 0x8063f30 next: 0x8063f70 segment: 0x806d6a8 type: mark bytes: 0 chars: 0 left mark `(null)' visible: 0 not_deleteable: 0 segment: 0x806d650 type: mark bytes: 0 chars: 0 right mark `gtk_drag_target' visible: 0 not_deleteable: 0 segment: 0x8133fd8 type: character bytes: 7 chars: 7 `0123456' segment: 0x8133990 type: mark bytes: 0 chars: 0 left mark `(null)' visible: 0 not_deleteable: 0 segment: 0x81339b8 type: character bytes: 1 chars: 1 `7' segment: 0x81339d0 type: mark bytes: 0 chars: 0 right mark `(null)' visible: 0 not_deleteable: 0 segment: 0x8064288 type: mark bytes: 0 chars: 0 right mark `insert' visible: 1 not_deleteable: 1 segment: 0x80642f0 type: mark bytes: 0 chars: 0 right mark `selection_bound' visible: 0 not_deleteable: 1 segment: 0x806d630 type: character bytes: 3 chars: 3 `89 ' 1| line: 0x8063f70 parent: 0x8063f30 next: (nil) segment: 0x8063fa0 type: character bytes: 1 chars: 1 ` ' =================== Tag information (no tags in the tree) =================== Tree nodes node 0x8063f30 level 0 children 2 lines 2 chars 12 line 0x8063f58 chars 11 bytes 11 left mark `(null)' visible: 0 right mark `gtk_drag_target' visible: 0 chars `0123456'... left mark `(null)' visible: 0 chars `7'... right mark `(null)' visible: 0 right mark `insert' visible: 1 right mark `selection_bound' visible: 0 chars `89\'... line 0x8063f70 chars 1 bytes 1 chars `\'... test (pid:26538): Gtk-ERROR **: file gtktextiter.c: line 2021 (_gtk_text_iter_forward_indexable_segment): assertion failed: (gtk_text_iter_is_end (iter)) aborting... Trace/breakpoint trap Important! If you uncomment the commented strings in the program source code and comment the next three strings (i.e. change the buffer initialization) the bug in not reproducible. The bug looks very similar to #64883 but probably is not its duplicate.
Was a bug in _gtk_text_iter_forward_indexable_segment() that depended on the exact segment structure of the btree; setting text on the buffer while it was in the view resulted in slightly different marks and thus different segments than setting text before placing the buffer in the view. 2001-11-29 Havoc Pennington <hp@redhat.com> * gtk/gtktextiter.c (_gtk_text_iter_forward_indexable_segment): assertion here that we were at the end iterator was not correct; change code to move us to the end iterator. bug #65731