[perl-Glib-Object-Introspection] Avoid repeating setting up a library
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] Avoid repeating setting up a library
- Date: Wed, 22 Jul 2015 13:04:07 +0000 (UTC)
commit 863ea335c3ad4f576f3447c244354098fbab66d8
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Wed Jul 22 15:03:13 2015 +0200
Avoid repeating setting up a library
This can lead to issues, e.g., due to types being registered more than once
with perl-Glib. In particular, the lazy-loading mechanism of Glib::Object is
not prepared to handle repeated type registrations.
NEWS | 5 +++++
gperl-i11n-vfunc-object.c | 2 +-
lib/Glib/Object/Introspection.pm | 13 ++++++++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6f31ee9..f80aa81 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Overview of changes in Glib::Object::Introspection <next>
+========================================================
+
+* Avoid repeating setting up a library as this can lead to issues.
+
Overview of changes in Glib::Object::Introspection 0.029
========================================================
diff --git a/gperl-i11n-vfunc-object.c b/gperl-i11n-vfunc-object.c
index 2f9be47..d1ab1c3 100644
--- a/gperl-i11n-vfunc-object.c
+++ b/gperl-i11n-vfunc-object.c
@@ -47,7 +47,7 @@ generic_class_init (GIObjectInfo *info, const gchar *target_package, gpointer cl
* struct member. */
HV * stash = gv_stashpv (target_package, 0);
GV * slot = gv_fetchmethod (stash, perl_method_name);
- if (!slot) {
+ if (!slot || !GvCV (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);
diff --git a/lib/Glib/Object/Introspection.pm b/lib/Glib/Object/Introspection.pm
index a37b39e..09a27d3 100644
--- a/lib/Glib/Object/Introspection.pm
+++ b/lib/Glib/Object/Introspection.pm
@@ -28,6 +28,7 @@ require XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
my @OBJECT_PACKAGES_WITH_VFUNCS;
+my %SEEN;
our %_FORBIDDEN_SUB_NAMES = map { $_ => 1 } qw/AUTOLOAD CLONE DESTROY BEGIN
UNITCHECK CHECK INIT END/;
our %_BASENAME_TO_PACKAGE;
@@ -68,6 +69,14 @@ sub setup {
my $search_path = $params{search_path} || undef;
my $name_corrections = $params{name_corrections} || {};
+ # Avoid repeating setting up a library as this can lead to issues, e.g., due
+ # to types being registered more than once with perl-Glib. In particular,
+ # the lazy-loading mechanism of Glib::Object is not prepared to handle
+ # repeated type registrations.
+ if ($SEEN{$basename}{$version}{$package}++) {
+ return;
+ }
+
$_BASENAME_TO_PACKAGE{$basename} = $package;
my %shift_package_name_for = exists $params{class_static_methods}
@@ -177,9 +186,11 @@ sub setup {
foreach my $packaged_signal (@use_generic_signal_marshaller_for) {
__PACKAGE__->_use_generic_signal_marshaller_for (@$packaged_signal);
}
+
+ return;
}
-sub INIT {
+INIT {
no strict qw(refs);
# Hook up the implemented vfuncs first.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]