Re: Gtk::TextBuffer::set_text() segfaulting



On Fri, 2008-02-22 at 20:37 +0000, Joe wrote:
> Ok, so the TextBuffer is going into a Gtk::TextView so is declared like:
> 
> 			  Glib::RefPtr<Gtk::TextBuffer>	buffer;

You do need to actually instantiate the TextBuffer. For instance:

buffer = Gtk::TextBuffer::create();

or get the default buffer:

buffer = textview.get_buffer();

In general you should not try to dereference pointers or smartpointers
before checking that they are not null.

> It seems when I run buffer->set_text() and pass either and std::string
> or a constant char array (ie put something like "cheese" into it) it
> causes a segmentation fault.
> 
> The TextBuffer is in the TextView when I try to set the text.
> 
> Anyone know what could cause this?

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com
> 



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