diff options
author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-01-10 23:39:04 +0000 |
---|---|---|
committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-01-10 23:39:04 +0000 |
commit | bbda25e94057a8e85da788aef894f92a50b1d5f1 (patch) | |
tree | 2583dfac27a17ffa974d0b707a8a89571ea4101c /gobject/pygobject-private.h | |
parent | d8d8f32a8537e1c3a447e23269450abb2b24d323 (diff) | |
download | pygobject-bbda25e94057a8e85da788aef894f92a50b1d5f1.tar.gz |
Bug 163612: segmentation fault on pygtk-demo
Diffstat (limited to 'gobject/pygobject-private.h')
-rw-r--r-- | gobject/pygobject-private.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h index a9d8bd90..d826f92e 100644 --- a/gobject/pygobject-private.h +++ b/gobject/pygobject-private.h @@ -19,20 +19,24 @@ extern struct _PyGObject_Functions pygobject_api_functions; (* pygobject_api_functions.unblock_threads)(); \ } G_STMT_END -#if PY_VERSION_HEX < 0x020400F0 -# define pyg_threads_enabled (pygobject_api_functions.threads_enabled) -#else -# define pyg_threads_enabled (PyEval_ThreadsInitialized()) -#endif +#define pyg_threads_enabled (pygobject_api_functions.threads_enabled) + -#define pyg_gil_state_ensure() (pyg_threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0) -#define pyg_gil_state_release(state) G_STMT_START { \ - if (pyg_threads_enabled) \ +#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0) +#define pyg_gil_state_release(state) G_STMT_START { \ + if (pygobject_api_functions.threads_enabled) \ pygobject_api_functions.gil_state_release(state); \ } G_STMT_END -#define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS -#define pyg_end_allow_threads Py_END_ALLOW_THREADS +#define pyg_begin_allow_threads \ + G_STMT_START { \ + PyThreadState *_save = NULL; \ + if (pygobject_api_functions.threads_enabled) \ + _save = PyEval_SaveThread(); +#define pyg_end_allow_threads \ + if (pygobject_api_functions.threads_enabled) \ + PyEval_RestoreThread(_save); \ + } G_STMT_END extern GType PY_TYPE_OBJECT; |