[pygobject] Initialize the foreign API at PyGI load time
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Initialize the foreign API at PyGI load time
- Date: Tue, 6 May 2014 03:27:10 +0000 (UTC)
commit 31ecd935564984068e6646676392122bdc03e42e
Author: Simon Feltman <sfeltman src gnome org>
Date: Mon May 5 19:42:59 2014 -0700
Initialize the foreign API at PyGI load time
Initialize the foreign struct list at gi._gi module load time. This ensures
we always have a valid (non-null) list of foreign marshalers outside of the
context of marshaling.
https://bugzilla.gnome.org/show_bug.cgi?id=694604
gi/gimodule.c | 3 ++-
gi/pygi-foreign.c | 12 ++++++++----
gi/pygi-foreign.h | 2 ++
3 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 1731190..47cd33c 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -661,13 +661,14 @@ PYGLIB_MODULE_START(_gi, "_gi")
PyModule_AddObject (module, "_gobject", _gobject_module);
PyModule_AddStringConstant(module, "__package__", "gi._gi");
+ pygi_foreign_init ();
pygi_error_register_types (module);
_pygi_repository_register_types (module);
_pygi_info_register_types (module);
_pygi_struct_register_types (module);
_pygi_boxed_register_types (module);
_pygi_ccallback_register_types (module);
- _pygi_argument_init();
+ _pygi_argument_init ();
/* Use RuntimeWarning as the base class of PyGIDeprecationWarning
* for unstable (odd minor version) and use DeprecationWarning for
diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c
index 6e0bf79..8a83c35 100644
--- a/gi/pygi-foreign.c
+++ b/gi/pygi-foreign.c
@@ -70,10 +70,6 @@ pygi_struct_foreign_lookup (GIBaseInfo *base_info)
const gchar *namespace = g_base_info_get_namespace (base_info);
const gchar *name = g_base_info_get_name (base_info);
- if (foreign_structs == NULL) {
- init_foreign_structs ();
- }
-
result = do_lookup (namespace, name);
if (result == NULL) {
@@ -166,3 +162,11 @@ pygi_register_foreign_struct (const char* namespace_,
g_ptr_array_add (foreign_structs, new_struct);
}
+
+void
+pygi_foreign_init (void)
+{
+ if (foreign_structs == NULL) {
+ init_foreign_structs ();
+ }
+}
diff --git a/gi/pygi-foreign.h b/gi/pygi-foreign.h
index acec069..ca4f75b 100644
--- a/gi/pygi-foreign.h
+++ b/gi/pygi-foreign.h
@@ -44,4 +44,6 @@ void pygi_register_foreign_struct (const char* namespace_,
PyGIArgOverrideFromGIArgumentFunc from_func,
PyGIArgOverrideReleaseFunc release_func);
+void pygi_foreign_init (void);
+
#endif /* __PYGI_FOREIGN_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]