Skip to content

Commit

Permalink
Bug 163612: segmentation fault on pygtk-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo J. A. M. Carneiro committed Jan 10, 2005
1 parent d8d8f32 commit bbda25e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
24 changes: 14 additions & 10 deletions gobject/pygobject-private.h
Expand Up @@ -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;
Expand Down
22 changes: 12 additions & 10 deletions gobject/pygobject.h
Expand Up @@ -223,21 +223,23 @@ struct _PyGObject_Functions *_PyGObject_API;
(* _PyGObject_API->unblock_threads)(); \
} G_STMT_END

#define pyg_threads_enabled (_PyGObject_API->threads_enabled)

#if PY_VERSION_HEX < 0x020400F0
# define pyg_threads_enabled (_PyGObject_API->threads_enabled)
#else
# define pyg_threads_enabled (PyEval_ThreadsInitialized())
#endif

#define pyg_gil_state_ensure() (pyg_threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0)
#define pyg_gil_state_ensure() (_PyGObject_API->threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0)
#define pyg_gil_state_release(state) G_STMT_START { \
if (pyg_threads_enabled) \
if (_PyGObject_API->threads_enabled) \
_PyGObject_API->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->threads_enabled) \
_save = PyEval_SaveThread();
#define pyg_end_allow_threads \
if (_PyGObject_API->threads_enabled) \
PyEval_RestoreThread(_save); \
} G_STMT_END

#define init_pygobject() { \
PyObject *gobject = PyImport_ImportModule("gobject"); \
Expand Down

0 comments on commit bbda25e

Please sign in to comment.