summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2004-08-03 18:38:14 +0000
committerJohan Dahlin <johan@src.gnome.org>2004-08-03 18:38:14 +0000
commit50b30e37d85c262ba1e78e434bbce99c928ce0ca (patch)
tree72980cef22c9e64db5888c8f55a39483421b7ddc
parent8cd34d3c6a74e51e6900cc386b2fc2e53f8f6ac9 (diff)
downloadpygtk-50b30e37d85c262ba1e78e434bbce99c928ce0ca.tar.gz
Urgh. more threading 'fixes'
-rw-r--r--configure.in5
-rw-r--r--gobject/gobjectmodule.c31
-rw-r--r--gobject/pygobject.h6
-rw-r--r--gtk/gdk.override10
-rw-r--r--pygtk-2.0.pc.in2
5 files changed, 27 insertions, 27 deletions
diff --git a/configure.in b/configure.in
index 6ace2bc9..b4a89e52 100644
--- a/configure.in
+++ b/configure.in
@@ -73,12 +73,15 @@ AM_CHECK_PYMOD(thread,,,enable_thread=no)
AC_MSG_CHECKING(whether to enable threading in pygtk)
if test "x$enable_thread" != xno; then
extra_mods=gthread
- AC_DEFINE(ENABLE_PYGTK_THREADING,,[enable threading support in pygtk])
+ THREADING_CFLAGS=
AC_MSG_RESULT(yes)
else
extra_mods=
+ THREADING_CFLAGS="-DDISABLE_THREADING"
AC_MSG_RESULT(no)
fi
+AC_SUBST(THREADING_CFLAGS)
+CPPFLAGS="${CPPFLAGS} $THREADING_CFLAGS"
dnl get rid of the -export-dynamic stuff from the configure flags ...
export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 4fd09cef..c45d89b0 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -96,7 +96,9 @@ static void
pyobject_free(gpointer boxed)
{
PyObject *object = boxed;
- PyGILState_STATE state = PyGILState_Ensure();
+ PyGILState_STATE state;
+
+ state = PyGILState_Ensure();
Py_DECREF(object);
PyGILState_Release(state);
}
@@ -1456,23 +1458,6 @@ pyg_main_context_default (PyObject *unused)
}
-static PyObject *
-pyg_thread_init (PyObject *unused)
-{
- /* FIXME: Should we raise an exception if we don't
- have threading enabled. This will make
- the import/initialize code quite ugly */
-#ifdef ENABLE_PYGTK_THREADING
- PyEval_InitThreads();
-
- if (!g_threads_got_initialized)
- g_thread_init(NULL);
-#endif
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
static PyMethodDef pygobject_functions[] = {
{ "type_name", pyg_type_name, METH_VARARGS },
{ "type_from_name", pyg_type_from_name, METH_VARARGS },
@@ -1490,7 +1475,6 @@ static PyMethodDef pygobject_functions[] = {
{ "io_add_watch", (PyCFunction)pyg_io_add_watch, METH_VARARGS|METH_KEYWORDS },
{ "source_remove", pyg_source_remove, METH_VARARGS },
{ "main_context_default", (PyCFunction)pyg_main_context_default, METH_NOARGS },
- { "thread_init", (PyCFunction)pyg_thread_init, METH_NOARGS },
{ NULL, NULL, 0 }
};
@@ -1826,10 +1810,17 @@ initgobject(void)
PyGTypeWrapper_Type.ob_type = &PyType_Type;
PyGParamSpec_Type.ob_type = &PyType_Type;
-
+
m = Py_InitModule("gobject", pygobject_functions);
d = PyModule_GetDict(m);
+#ifndef DISABLE_THREADING
+ PyEval_InitThreads();
+ if (!g_threads_got_initialized)
+ g_thread_init(NULL);
+#else
+
+#endif
g_type_init();
PY_TYPE_OBJECT = g_boxed_type_register_static("PyObject",
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index c9cebfed..43ea6641 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -7,6 +7,12 @@
#include <glib.h>
#include <glib-object.h>
+#ifdef DISABLE_THREADING
+# define PyGILState_STATE int
+# define PyGILState_Ensure() (0)
+# define PyGILState_Release(x)
+#endif
+
typedef struct {
PyObject_HEAD
GObject *obj;
diff --git a/gtk/gdk.override b/gtk/gdk.override
index 215dc395..3223e07c 100644
--- a/gtk/gdk.override
+++ b/gtk/gdk.override
@@ -86,7 +86,7 @@ override gdk_threads_init noargs
* given the nature of Python threading, this option is not
* particularly appealing.
*/
-#ifdef ENABLE_PYGTK_THREADING
+#ifndef DISABLE_THREADING
static GStaticPrivate pythreadstate_key = G_STATIC_PRIVATE_INIT;
static GStaticPrivate lock_count_key = G_STATIC_PRIVATE_INIT;
static PyInterpreterState *pyinterpstate = NULL;
@@ -97,9 +97,9 @@ pygdk_get_lock_count(void)
gint *lock_count = g_static_private_get(&lock_count_key);
if(!lock_count) {
- lock_count = g_malloc(sizeof(gint));
- *lock_count = 1;
- g_static_private_set(&lock_count_key, lock_count, NULL);
+ lock_count = g_malloc(sizeof(gint));
+ *lock_count = 1;
+ g_static_private_set(&lock_count_key, lock_count, NULL);
}
return lock_count;
@@ -137,7 +137,7 @@ pygdk_unblock_threads (void)
static PyObject *
_wrap_gdk_threads_init(PyObject *self)
{
-#ifdef ENABLE_PYGTK_THREADING
+#ifndef DISABLE_THREADING
/* register gdk thread block/unblock routines with gobjectmodule */
pyg_set_thread_block_funcs (pygdk_block_threads, pygdk_unblock_threads);
diff --git a/pygtk-2.0.pc.in b/pygtk-2.0.pc.in
index ff17aeb5..799d0933 100644
--- a/pygtk-2.0.pc.in
+++ b/pygtk-2.0.pc.in
@@ -17,4 +17,4 @@ Name: PyGTK
Description: Python bindings for GTK+ and related libraries
Requires: gobject-2.0
Version: @VERSION@
-Cflags: -I${pygtkincludedir}
+Cflags: -I${pygtkincludedir} @THREADING_CFLAGS@