diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2022-08-18 19:05:33 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2022-08-18 19:05:33 (GMT) |
commit | f22f73bcbdb6510169c8b7c7c3fea842750c6fe5 (patch) | |
tree | c621257695d9f132dff88b9149ee86d3b0888236 /plugins/pychrysalide/analysis | |
parent | 429b54556283116a29c5d699af0cf891bb1c1055 (diff) |
Handle the Python Global Interpreter Lock with more care.
Diffstat (limited to 'plugins/pychrysalide/analysis')
-rw-r--r-- | plugins/pychrysalide/analysis/type.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/type.c b/plugins/pychrysalide/analysis/type.c index 86a0ffb..357d381 100644 --- a/plugins/pychrysalide/analysis/type.c +++ b/plugins/pychrysalide/analysis/type.c @@ -220,6 +220,7 @@ static void py_data_type_init_gclass(GDataTypeClass *class, gpointer unused) static guint py_data_type_hash_wrapper(const GDataType *type) { guint result; /* Empreinte à renvoyer */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ @@ -234,6 +235,8 @@ static guint py_data_type_hash_wrapper(const GDataType *type) result = 0; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_hash")) @@ -252,6 +255,8 @@ static guint py_data_type_hash_wrapper(const GDataType *type) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } @@ -272,6 +277,7 @@ static guint py_data_type_hash_wrapper(const GDataType *type) static GDataType *py_data_type_dup_wrapper(const GDataType *type) { GDataType *result; /* Copie à retourner */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ @@ -287,6 +293,8 @@ static GDataType *py_data_type_dup_wrapper(const GDataType *type) result = NULL; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_dup")) @@ -308,6 +316,8 @@ static GDataType *py_data_type_dup_wrapper(const GDataType *type) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } @@ -329,6 +339,7 @@ static GDataType *py_data_type_dup_wrapper(const GDataType *type) static char *py_data_type_to_string_wrapper(const GDataType *type, bool include) { char *result; /* Etiquette à retourner */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *arg; /* Version Python de l'argument*/ PyObject *args; /* Arguments pour l'appel */ @@ -349,6 +360,8 @@ static char *py_data_type_to_string_wrapper(const GDataType *type, bool include) result = NULL; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_to_string")) @@ -375,6 +388,8 @@ static char *py_data_type_to_string_wrapper(const GDataType *type, bool include) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } @@ -395,6 +410,7 @@ static char *py_data_type_to_string_wrapper(const GDataType *type, bool include) static bool py_data_type_handle_namespaces_wrapper(const GDataType *type) { bool result; /* Bilan à retourner */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ @@ -411,6 +427,8 @@ static bool py_data_type_handle_namespaces_wrapper(const GDataType *type) result = true; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_handle_namespaces")) @@ -425,6 +443,8 @@ static bool py_data_type_handle_namespaces_wrapper(const GDataType *type) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } @@ -445,6 +465,7 @@ static bool py_data_type_handle_namespaces_wrapper(const GDataType *type) static bool py_data_type_is_pointer_wrapper(const GDataType *type) { bool result; /* Bilan à retourner */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ @@ -461,6 +482,8 @@ static bool py_data_type_is_pointer_wrapper(const GDataType *type) result = false; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_is_pointer")) @@ -475,6 +498,8 @@ static bool py_data_type_is_pointer_wrapper(const GDataType *type) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } @@ -495,6 +520,7 @@ static bool py_data_type_is_pointer_wrapper(const GDataType *type) static bool py_data_type_is_reference_wrapper(const GDataType *type) { bool result; /* Bilan à retourner */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ @@ -511,6 +537,8 @@ static bool py_data_type_is_reference_wrapper(const GDataType *type) result = false; + gstate = PyGILState_Ensure(); + pyobj = pygobject_new(G_OBJECT(type)); if (has_python_method(pyobj, "_is_reference")) @@ -525,6 +553,8 @@ static bool py_data_type_is_reference_wrapper(const GDataType *type) Py_DECREF(pyobj); + PyGILState_Release(gstate); + return result; } |