Re: Subclassing question

Martin Schlemmer wrote:
I have a class that overrides Gtk2::TextBuffer's insert_text signal to disallow
adding newlines to the buffer.  The problem however seems to be that when
the signal is overridden, the iterator is no longer updated causing it to be
invalid - I assume its because its no longer pass as reference.

This appears to be a bug in the bindings. The problem is that Glib::Object::signal_chain_from_overridden ends up passing a copy of the iter to the original C signal handler. This copy is then correctly revalidated, but that doesn't affect the original iter, of course.

Technically, this is due to gperl_value_from_sv using g_value_set_boxed instead of g_value_set_static_boxed. The former copies the boxed object. I can't think of a reason not to use g_value_set_static_boxed there (other than "being defensive"). When I do this change, Glib's and Gtk2's test suites still pass.

muppet, do you remember why gperl_value_from_sv uses g_value_set_boxed instead of g_value_set_static_boxed?

Is there any way to do this with the current Glib::Object::Subclass interface
or perl?

Other than overriding every insert() method of Gtk2::TextBuffer with your own variant (with normal method overloading), the only workaround I can think of is not to rely on the iter-revalidating behavior of insert() in user code.

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