summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-10-07 23:12:34 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-10-07 23:12:34 (GMT)
commitcb23e316fbf507e4eebca1551ca25f5bcff9d56f (patch)
tree549a850f9392bf16e224f3aafea0c76d7603bc09 /plugins
parentce8523394ea49b91228e6f05a738d72d14b2e5c1 (diff)
Fixed again bugs with the Python global lock at exit.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pychrysalide/plugin.c16
-rw-r--r--plugins/pychrysalide/pychrysa.c29
-rw-r--r--plugins/pychrysalide/pychrysa.h3
3 files changed, 44 insertions, 4 deletions
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c
index c42235a..eb6d00d 100644
--- a/plugins/pychrysalide/plugin.c
+++ b/plugins/pychrysalide/plugin.c
@@ -37,6 +37,7 @@
#include "access.h"
#include "helpers.h"
+#include "pychrysa.h"
@@ -178,16 +179,25 @@ static void g_python_plugin_dispose(GPythonPlugin *plugin)
* comme dépréciée depuis Python 3.2.
*
* Donc on choisit les alternatives officielles.
+ *
+ * Cependant, PyThreadState_Get() renvoit l'erreur suivante :
+ *
+ * Fatal Python error: PyThreadState_Get: no current thread
+ *
+ * Donc on se rabat sur une sauvegarde, qui n'est initialisée que lorsque l'interpréteur
+ * est intégré dans l'éditeur.
*/
- tstate = PyThreadState_Get();
+ tstate = get_pychrysalide_main_tstate();
- PyEval_RestoreThread(tstate);
+ if (tstate != NULL)
+ PyEval_RestoreThread(tstate);
Py_XDECREF(plugin->instance);
plugin->instance = NULL;
- PyEval_SaveThread();
+ if (tstate != NULL)
+ PyEval_SaveThread();
G_OBJECT_CLASS(g_python_plugin_parent_class)->dispose(G_OBJECT(plugin));
diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c
index 200bdaa..c6a114f 100644
--- a/plugins/pychrysalide/pychrysa.c
+++ b/plugins/pychrysalide/pychrysa.c
@@ -70,6 +70,9 @@ static bool _standalone = true;
/* Réceptacle pour le chargement forcé */
static PyObject *_chrysalide_module = NULL;
+/* Conservation des informations du thread principal */
+static PyThreadState *_main_tstate = NULL;
+
/* Fournit la révision du programme global. */
static PyObject *py_chrysalide_revision(PyObject *, PyObject *);
@@ -602,6 +605,8 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
else
result = load_python_plugins(plugin);
+ _main_tstate = PyThreadState_Get();
+
PyEval_ReleaseLock();
cpi_done:
@@ -611,7 +616,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
}
-
/******************************************************************************
* *
* Paramètres : plugin = greffon à manipuler. *
@@ -629,3 +633,26 @@ G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin)
Py_XDECREF(_chrysalide_module);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit les informations du thread principal. *
+* *
+* Retour : Indications utiles à Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyThreadState *get_pychrysalide_main_tstate(void)
+{
+ PyThreadState *result; /* Indications à retourner */
+
+ result = _main_tstate;
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/pychrysa.h b/plugins/pychrysalide/pychrysa.h
index e1fecd6..ef5c545 100644
--- a/plugins/pychrysalide/pychrysa.h
+++ b/plugins/pychrysalide/pychrysa.h
@@ -94,6 +94,9 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *);
/* Prend acte du déchargement du greffon. */
G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *);
+/* Fournit les informations du thread principal. */
+PyThreadState *get_pychrysalide_main_tstate(void);
+
#endif /* _PLUGINS_PYCHRYSALIDE_H */