summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/item.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gui/item.c')
-rw-r--r--plugins/pychrysalide/gui/item.c62
1 files changed, 21 insertions, 41 deletions
diff --git a/plugins/pychrysalide/gui/item.c b/plugins/pychrysalide/gui/item.c
index 2046587..0c604b5 100644
--- a/plugins/pychrysalide/gui/item.c
+++ b/plugins/pychrysalide/gui/item.c
@@ -291,19 +291,16 @@ static GtkWidget *py_editor_item_get_widget_wrapper(const GEditorItem *item)
static void py_editor_item_change_content_wrapper(GEditorItem *item, GLoadedContent *old, GLoadedContent *new)
{
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
PyObject *pyobj; /* Objet Python concerné */
- PyThreadState *tstate; /* Contexte d'environnement */
PyObject *pyold; /* Conversion ou None */
PyObject *pynew; /* Conversion ou None */
PyObject *args; /* Arguments pour l'appel */
PyObject *pyret; /* Retour de Python */
- pyobj = pygobject_new(G_OBJECT(item));
-
- tstate = get_pychrysalide_main_tstate();
+ gstate = PyGILState_Ensure();
- if (tstate != NULL)
- PyEval_RestoreThread(tstate);
+ pyobj = pygobject_new(G_OBJECT(item));
if (has_python_method(pyobj, "_change_content"))
{
@@ -334,8 +331,7 @@ static void py_editor_item_change_content_wrapper(GEditorItem *item, GLoadedCont
}
- if (tstate != NULL)
- PyEval_SaveThread();
+ PyGILState_Release(gstate);
}
@@ -356,19 +352,16 @@ static void py_editor_item_change_content_wrapper(GEditorItem *item, GLoadedCont
static void py_editor_item_change_view_wrapper(GEditorItem *item, GLoadedPanel *old, GLoadedPanel *new)
{
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
PyObject *pyobj; /* Objet Python concerné */
- PyThreadState *tstate; /* Contexte d'environnement */
PyObject *pyold; /* Conversion ou None */
PyObject *pynew; /* Conversion ou None */
PyObject *args; /* Arguments pour l'appel */
PyObject *pyret; /* Retour de Python */
- pyobj = pygobject_new(G_OBJECT(item));
-
- tstate = get_pychrysalide_main_tstate();
+ gstate = PyGILState_Ensure();
- if (tstate != NULL)
- PyEval_RestoreThread(tstate);
+ pyobj = pygobject_new(G_OBJECT(item));
if (has_python_method(pyobj, "_change_view"))
{
@@ -399,8 +392,7 @@ static void py_editor_item_change_view_wrapper(GEditorItem *item, GLoadedPanel *
}
- if (tstate != NULL)
- PyEval_SaveThread();
+ PyGILState_Release(gstate);
}
@@ -420,17 +412,14 @@ static void py_editor_item_change_view_wrapper(GEditorItem *item, GLoadedPanel *
static void py_editor_item_update_view_wrapper(GEditorItem *item, GLoadedPanel *panel)
{
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
PyObject *pyobj; /* Objet Python concerné */
- PyThreadState *tstate; /* Contexte d'environnement */
PyObject *args; /* Arguments pour l'appel */
PyObject *pyret; /* Retour de Python */
- pyobj = pygobject_new(G_OBJECT(item));
-
- tstate = get_pychrysalide_main_tstate();
+ gstate = PyGILState_Ensure();
- if (tstate != NULL)
- PyEval_RestoreThread(tstate);
+ pyobj = pygobject_new(G_OBJECT(item));
if (has_python_method(pyobj, "_update_view"))
{
@@ -444,8 +433,7 @@ static void py_editor_item_update_view_wrapper(GEditorItem *item, GLoadedPanel *
}
- if (tstate != NULL)
- PyEval_SaveThread();
+ PyGILState_Release(gstate);
}
@@ -466,17 +454,14 @@ static void py_editor_item_update_view_wrapper(GEditorItem *item, GLoadedPanel *
static void py_editor_item_track_cursor_wrapper(GEditorItem *item, GLoadedPanel *panel, const GLineCursor *cursor)
{
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
PyObject *pyobj; /* Objet Python concerné */
- PyThreadState *tstate; /* Contexte d'environnement */
PyObject *args; /* Arguments pour l'appel */
PyObject *pyret; /* Retour de Python */
- pyobj = pygobject_new(G_OBJECT(item));
-
- tstate = get_pychrysalide_main_tstate();
+ gstate = PyGILState_Ensure();
- if (tstate != NULL)
- PyEval_RestoreThread(tstate);
+ pyobj = pygobject_new(G_OBJECT(item));
if (has_python_method(pyobj, "_track_cursor"))
{
@@ -491,8 +476,7 @@ static void py_editor_item_track_cursor_wrapper(GEditorItem *item, GLoadedPanel
}
- if (tstate != NULL)
- PyEval_SaveThread();
+ PyGILState_Release(gstate);
}
@@ -513,17 +497,14 @@ static void py_editor_item_track_cursor_wrapper(GEditorItem *item, GLoadedPanel
static void py_editor_item_focus_cursor_wrapper(GEditorItem *item, GLoadedContent *content, const GLineCursor *cursor)
{
+ PyGILState_STATE gstate; /* Sauvegarde d'environnement */
PyObject *pyobj; /* Objet Python concerné */
- PyThreadState *tstate; /* Contexte d'environnement */
PyObject *args; /* Arguments pour l'appel */
PyObject *pyret; /* Retour de Python */
- pyobj = pygobject_new(G_OBJECT(item));
-
- tstate = get_pychrysalide_main_tstate();
+ gstate = PyGILState_Ensure();
- if (tstate != NULL)
- PyEval_RestoreThread(tstate);
+ pyobj = pygobject_new(G_OBJECT(item));
if (has_python_method(pyobj, "_focus_cursor"))
{
@@ -538,8 +519,7 @@ static void py_editor_item_focus_cursor_wrapper(GEditorItem *item, GLoadedConten
}
- if (tstate != NULL)
- PyEval_SaveThread();
+ PyGILState_Release(gstate);
}
@@ -711,7 +691,7 @@ bool ensure_python_editor_item_is_registered(void)
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_EDITOR_ITEM, type, &PyGObject_Type))
+ if (!register_class_for_pygobject(dict, G_TYPE_EDITOR_ITEM, type))
return false;
}