diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2014-05-05 19:42:59 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-05-05 20:24:32 -0700 |
commit | 31ecd935564984068e6646676392122bdc03e42e (patch) | |
tree | 27bd4b69f8ed6afc24015d5a3e8939eda738b96e /gi | |
parent | def47144b63a1492ebf47a4eadb535f45253ff3a (diff) | |
download | pygobject-31ecd935564984068e6646676392122bdc03e42e.tar.gz |
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
Diffstat (limited to 'gi')
-rw-r--r-- | gi/gimodule.c | 3 | ||||
-rw-r--r-- | gi/pygi-foreign.c | 12 | ||||
-rw-r--r-- | gi/pygi-foreign.h | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c index 1731190c..47cd33ca 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 6e0bf79d..8a83c351 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 acec0698..ca4f75b6 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__ */ |