Re: Problem with subclassing with Glib::Object::Subclass and Gtk3



"Yuri Myasoedov" <ymyasoedov yandex ru>:
Hm. It seems the problem is in Glib::Object::Introspection XS function _invoke_fallback_vfunc:

__PACKAGE__->_invoke_fallback_vfunc($provider_package,
                                                $vfunc_name,
                                                $implementer_package,
                                                 _);

It can't handle undef parameters. For example, in "screen-changed" handler (I didn't connect any handlers 
to this signal in my class):

void user_function (GtkWidget *widget, GdkScreen *previous_screen, gpointer   user_data)

where "previous_screen" -- the previous screen, or NULL if the widget was not associated with a screen 
before.

In my case "previous_screen" is undef because it should be NULL in C. But Glib::Object::Introspection 
requires that "previous_screen" should be Gtk3::Gdk::Screen and it fails when "previous_screen" is undef: 
"undef is not of type Gtk3::Gdk::Screen".

To avoid segfaults, Glib::Object::Introspection disallows undef for pointer arguments that are not marked as 
accepting NULL.  There is probably no "allow-none" annotation for the "previous_screen" argument of the 
"screen_changed" vfunc (check in <prefix>/share/gir-1.0/Gtk-3.0.gir).

https://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.h#n555

There is support in gobject-introspection for applying annotations to a vfunc that come from its invoker:

https://mail.gnome.org/archives/commits-list/2010-June/msg05341.html

But for "screen_changed" there does not seem to be an invoker, only a signal.  The signal does have the 
correct annotation:

https://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.c#n3500

So, one option would be to add support to gobject-introspection for applying annotations to a vfunc from its 
associated signal.  Another would be to suppress the undef-checking when invoking fallback vfuncs in 
Glib::Object::Introspection.  Suggestions?


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