summaryrefslogtreecommitdiffstats
path: root/gobject/pygobject.h
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@src.gnome.org>2004-09-27 17:57:41 +0000
committerJohn Ehresman <jpe@src.gnome.org>2004-09-27 17:57:41 +0000
commit5af9d80f2cced90b86b425fd3011b5cbed3b975b (patch)
tree2c0801617d2188adb867a57f67b571bb54cef183 /gobject/pygobject.h
parent4e66fa1cfa6d35ae97fc94a0c715abb04b79a0c3 (diff)
downloadpygobject-5af9d80f2cced90b86b425fd3011b5cbed3b975b.tar.gz
pygobject-5af9d80f2cced90b86b425fd3011b5cbed3b975b.tar.xz
pygobject-5af9d80f2cced90b86b425fd3011b5cbed3b975b.zip
New functions exposed through _PyGObject_Functions to work around bugs in
* gobject/gobjectmodule.c: New functions exposed through _PyGObject_Functions to work around bugs in the PyGILState api's * gobject/pygobject.h: idem * gobject/pygobject-private.h: idem * gtk/gtk.override (_wrap_gtk_main): add pyg_enable_threads() call to ensure thread state for thread invoking this function is remembered. Only call pyg_enable_threads() here if threads were previously enabled
Diffstat (limited to 'gobject/pygobject.h')
-rw-r--r--gobject/pygobject.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index 14a83c2..4c99031 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -7,6 +7,11 @@
#include <glib.h>
#include <glib-object.h>
+/* Work around bugs in PyGILState api fixed in 2.4.0a4 */
+#if PY_HEXVERSION < 0x020400A4
+#define PYGIL_API_IS_BUGGY
+#endif
+
/* PyGClosure is a _private_ structure */
typedef struct _PyGClosure PyGClosure;
struct _PyGClosure {
@@ -144,6 +149,8 @@ struct _PyGObject_Functions {
gboolean threads_enabled;
int (*enable_threads) (void);
+ int (*gil_state_ensure) (void);
+ void (*gil_state_release) (int flag);
};
#ifndef _INSIDE_PYGOBJECT_
@@ -206,11 +213,22 @@ struct _PyGObject_Functions *_PyGObject_API;
} G_STMT_END
#define pyg_threads_enabled (_PyGObject_API->threads_enabled)
+
+#ifndef PYGIL_API_IS_BUGGY
#define pyg_gil_state_ensure() (_PyGObject_API->threads_enabled? (PyGILState_Ensure()) : 0)
#define pyg_gil_state_release(state) G_STMT_START { \
if (_PyGObject_API->threads_enabled) \
PyGILState_Release(state); \
} G_STMT_END
+#else
+#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 (_PyGObject_API->threads_enabled) \
+ _PyGObject_API->gil_state_release(state); \
+ } G_STMT_END
+
+#endif
+
#define pyg_begin_allow_threads \
G_STMT_START { \
PyThreadState *_save = NULL; \