Skip Menu |

This queue is for tickets about the Glib-Object-Introspection CPAN distribution.

Report information
The Basics
Id: 103544
Status: resolved
Priority: 0/
Queue: Glib-Object-Introspection

People
Owner: Nobody in particular
Requestors: MYASOEDOV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.029
Fixed in: (no value)



Subject: Incorrect object initialization of inherited class created with Glib::Object::Subclass
Glib::Object::Introspection initialize objects incorrectly if their classes have been inherited with Glib::Object::Subclass module. For example, this code will fail with error "Can't locate object method "PARENT_SET" via package "MyButton"": package MyButton; use Gtk3; use Glib::Object::Subclass Gtk3::Button::, signals => {}, properties => [], ; sub INIT_INSTANCE { my $self = shift; return $self; } package main; use Gtk3 -init; my $window = Gtk3::Window->new(); $window->signal_connect(delete_event => sub { Gtk3->main_quit() }); my $my_button = MyButton->new("Test"); $window->add($my_button); $window->show_all(); Gtk3->main(); "parent_set" is non-implemented vfunc. The problem is in gperl-i11n-vfunc-object.c : ... /* If there is no implementation of this vfunc at INIT * time, we assume that the intention is to provide no * implementation and we thus skip setting up the class * struct member. */ HV * stash = gv_stashpv (target_package, 0); GV * slot = gv_fetchmethod (stash, perl_method_name); if (!slot) { dwarn ("skipping vfunc %s.%s because it has no implementation\n", g_base_info_get_name (info), vfunc_name); g_base_info_unref (vfunc_info); g_free (perl_method_name); continue; } } ... where "gv_fetchmethod" is just a macro for "gv_fetchmethod_autoload": #define gv_fetchmethod(stash, name) gv_fetchmethod_autoload(stash, name, TRUE) But is doesn't allow us to find non-implemented vfuncs. Because it looks for them in AUTOLOAD, if it can't find them in implemented methods. To fix this we need to replace "gv_fetchmethod" with "gv_fetchmethod_autoload": GV * slot = gv_fetchmethod_autoload (stash, perl_method_name, FALSE); Patch has been attached.
Subject: fix-searching-vfuncs.patch
--- a.c 2015-04-14 19:58:49.000000000 +0300 +++ b.c 2015-04-14 13:39:05.437775480 +0300 @@ -46,7 +46,7 @@ * implementation and we thus skip setting up the class * struct member. */ HV * stash = gv_stashpv (target_package, 0); - GV * slot = gv_fetchmethod (stash, perl_method_name); + GV * slot = gv_fetchmethod_autoload (stash, perl_method_name, FALSE); if (!slot) { dwarn ("skipping vfunc %s.%s because it has no implementation\n", g_base_info_get_name (info), vfunc_name);
Show quoted text
> Patch has been attached.
Sorry, wrong paths/filenames in the header. Here is the fixed one.
Subject: fix-searching-vfuncs.patch
--- a/gperl-i11n-vfunc-object.c 2015-04-15 15:27:28.042594369 +0300 +++ b/gperl-i11n-vfunc-object.c 2015-04-15 15:28:34.068903341 +0300 @@ -46,7 +46,7 @@ * implementation and we thus skip setting up the class * struct member. */ HV * stash = gv_stashpv (target_package, 0); - GV * slot = gv_fetchmethod (stash, perl_method_name); + GV * slot = gv_fetchmethod_autoload (stash, perl_method_name, FALSE); if (!slot) { dwarn ("skipping vfunc %s.%s because it has no implementation\n", g_base_info_get_name (info), vfunc_name);
Subject: Re: [rt.cpan.org #103544] Incorrect object initialization of inherited class created with Glib::Object::Subclass
Date: Wed, 22 Jul 2015 15:20:58 +0200
To: bug-Glib-Object-Introspection [...] rt.cpan.org
From: Torsten Schönfeld <kaffeetisch [...] gmx.de>
RT-Send-CC: kaffeetisch [...] gmx.de
Срд Июл 22 09:21:11 2015, TSCH писал: Show quoted text
> I think I've now tracked the problem down and fixed it: > > https://git.gnome.org/browse/perl-Glib-Object- > Introspection/commit/?id=863ea335c3ad4f576f3447c244354098fbab66d8 > https://git.gnome.org/browse/perl- > Gtk3/commit/?id=edc061ec863828ca801d9183299de0978d60f192 > > So please try again with Glib::Object::Introspection from git master.
It seems, it works now. I'm closing this ticket.