[pygtk] TextBuffer and g_utf8_validate

2002-03-04 Thread Pier Carteri

Hi,
as said in my previous post (I hope not boring you ) I'm working on a
code editor based on GtkTextBuffer and GtkTextView; the method for load
a file is something like this:
try:
file=open(self.name,'r')
text=file.read()
start=self.buffer.get_start_iter()
self.buffer.insert(start,text,-1)
self.set_save_point()
except:
do somethings

Usually everythings works as supposed but sometimes I have the following
error:

editor(pid:1549): Gtk-CRITICAL **: file gtktextbuffer.c line 476
(gtk_text_buffer_emit_insert): assertion 'g_utf8_validate (text, len,
NULL)' failed

The files are normal text file; where is the error?

(gtk2 1.3.14 python2.2 pygtk 1.99.7)

Thank you!

Pier


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



Re: [pygtk] TextBuffer and g_utf8_validate

2002-03-04 Thread Matt Wilson

In Python the insert method doesn't need the length argument - it is
optional.  If omitted it will use the length of the string passed in
automatically.

Cheers,

Matt 

On Mon, Mar 04, 2002 at 03:19:30PM +0100, Pier Carteri wrote:
 I'm sorry, probably I must count to 10  before sending a mail to the
 list, because the solution was in front of me :-P 
 Reading the c doc of gtk2 I've notice that if I use
 
 self.buffer.insert(start,text,-1)
 
 the string must be Null terminated; so I've changed that line with
 
 self.buffer.insert(start,text,len(text))
 
 and everythings works!
 Sorry again for the spam
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk