|
我写一个往gtktextview中插入数据的函数,
void
insert_text_to_text4 (gchar * data)
{
GtkTextBuffer *buffer;
GtkTextIter end;
buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text4)); //text4是一个gtktextview控件
gtk_text_buffer_get_end_iter(buffer,&end);
gtk_text_buffer_insert(buffer, &end, data, -1);
gtk_text_buffer_get_end_iter(buffer,&end);
gtk_text_buffer_insert(buffer, &end, "\n", -1);
}
在进行插入的时候大部分时候正常.但偶尔会出现如下的错误:
Gtk-WARNING **: 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
段错误 |
|