summaryrefslogtreecommitdiff
path: root/loaders
diff options
context:
space:
mode:
authorGarrett Regier <Garrett.Regier@riftio.com>2014-07-22 15:17:18 -0400
committerGarrett Regier <Garrett.Regier@riftio.com>2014-07-22 15:17:18 -0400
commita5bce456109604b0490551a6914e386741a32a05 (patch)
treec6e889b008470b875a9e372a7487757eb1cdc6dd /loaders
parent3fe26b14fa61ab0a70ab7bbe4938ea2650ca39c3 (diff)
downloadlibpeas-a5bce456109604b0490551a6914e386741a32a05.tar.gz
Bug 732155 - Fix initializing Python loader from Python application
https://bugzilla.gnome.org/show_bug.cgi?id=732155
Diffstat (limited to 'loaders')
-rw-r--r--loaders/python/peas-plugin-loader-python.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index ed018a3..91a3d41 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -375,6 +375,7 @@ static gboolean
peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
{
PeasPluginLoaderPython *pyloader = PEAS_PLUGIN_LOADER_PYTHON (loader);
+ PyGILState_STATE state = 0;
long hexversion;
PyObject *gettext, *result;
const gchar *prgname;
@@ -390,7 +391,11 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
pyloader->priv->init_failed = TRUE;
/* Python initialization */
- if (!Py_IsInitialized ())
+ if (Py_IsInitialized ())
+ {
+ state = PyGILState_Ensure ();
+ }
+ else
{
#ifdef HAVE_SIGACTION
struct sigaction sigint;
@@ -506,7 +511,10 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
/* Python has been successfully initialized */
pyloader->priv->init_failed = FALSE;
- pyloader->priv->py_thread_state = PyEval_SaveThread ();
+ if (!pyloader->priv->must_finalize_python)
+ PyGILState_Release (state);
+ else
+ pyloader->priv->py_thread_state = PyEval_SaveThread ();
return TRUE;
@@ -518,6 +526,9 @@ python_init_error:
if (PyErr_Occurred ())
PyErr_Clear ();
+ if (!pyloader->priv->must_finalize_python)
+ PyGILState_Release (state);
+
return FALSE;
}