[libpeas] Don't finalize python if we didn't initialize it.



commit 845cbad8527f990d8d9e8d3a0f66aed8a2bc1eca
Author: Steve Frécinaux <code istique net>
Date:   Sun Jun 27 20:11:06 2010 +0200

    Don't finalize python if we didn't initialize it.
    
    This is to avoid weird effects on other components that might be using
    python if we didn't initialize it ourselves.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620060

 loaders/python/peas-plugin-loader-python.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index b728e92..e79736f 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -43,7 +43,8 @@ typedef int Py_ssize_t;
 struct _PeasPluginLoaderPythonPrivate {
   GHashTable *loaded_plugins;
   guint idle_gc;
-  gboolean init_failed;
+  guint init_failed : 1;
+  guint must_finalize_python : 1;
 };
 
 typedef struct {
@@ -340,7 +341,8 @@ peas_python_shutdown (PeasPluginLoaderPython *loader)
   while (PyGC_Collect ())
     ;
 
-  Py_Finalize ();
+  if (loader->priv->must_finalize_python)
+    Py_Finalize ();
 }
 
 /* C equivalent of
@@ -393,7 +395,10 @@ peas_python_init (PeasPluginLoaderPython *loader)
 
   /* Python initialization */
   if (!Py_IsInitialized ())
-    Py_InitializeEx (FALSE);
+    {
+      Py_InitializeEx (FALSE);
+      loader->priv->must_finalize_python = TRUE;
+    }
 
   prgname = g_get_prgname ();
   if (prgname != NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]