Re: Using a Const Gtk::TextBuffer Object?



>  Hello,
>
> I've noticed that the method:
> Glib::ustring Gtk::TextBuffer::get_text(bool include_hidden_chars=true);
> is non-const. Is this by design? Since it returns a Glib::ustring, *not* a
> reference, shouldn't it logically avoid
> modifying a Gtk::TextBuffer object?

Yes, it should be const. I'll add a const overload in the HEAD branch.
Please use bugzilla if I forget.

> I've run into this problem while writing a widget that subclasses
> Gtk::TextView, but has a more Gtk::Entry-like interface. I can only
> implement my widget's
> Glib::ustring get_text() const
> member by const-casting in the body of the method.

Yes, that's an appropriate workaround.

> Shouldn't the
> const-cast
> be (if at all) in the body of Gtk::TextBuffer::get_text?

Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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