Re: Problem with subclassing with Glib::Object::Subclass and Gtk3
- From: Yuri Myasoedov <ymyasoedov yandex ru>
- To: "gtk-perl-list gnome org" <gtk-perl-list gnome org>
- Subject: Re: Problem with subclassing with Glib::Object::Subclass and Gtk3
- Date: Tue, 14 Apr 2015 14:27:26 +0300
10.04.2015, 17:09, "Yuri Myasoedov" <ymyasoedov yandex ru>:
I've tried to fix Gtk-3.0.gir and rebuilt it with g-ir-compiler. I added "allow-none" to vfuncs
"signal_changed", "style_set" and then I got a segfault on method "adjust_size_request". I've attached full
backtrace if it could help to locate the issue.
But I still can't understand, why I need to reimplement methods PARENT_SET, HIERARCHY_CHANGED, EVENT,
otherwise my code fails with an error like "Can't locate object method "PARENT_SET" via package "MyButton"
at /usr/local/lib/x86_64-linux-gnu/perl/5.20.1/Glib/Object/Introspection.pm line 58". Something is wrong
with that.
I've fixed it.
The bug was in Glib::Object::Introspection module. If file
perl-Glib-Object-Introspection/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;
}
}
...
But "gv_fetchmethod" is just a macro for "gv_fetchmethod_autoload":
#define gv_fetchmethod(stash, name) gv_fetchmethod_autoload(stash, name, TRUE)
That doesn't allow us to find non-implemented vfuncs. After replacing "gv_fetchmethod" with
"gv_fetchmethod_autoload":
GV * slot = gv_fetchmethod_autoload (stash, perl_method_name, FALSE);
my code starts to work properly! I don't need to implement HIERARCHY_CHANGED, PARENT_SET and other
non-implemented vfuncs.
I would like to ask Torsten or Brian to confirm this problem and review my improvement.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]