diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | TODO | 11 | ||||
-rw-r--r-- | gtk/gdk.override | 47 |
3 files changed, 33 insertions, 30 deletions
@@ -1,3 +1,8 @@ +2003-07-26 James Henstridge <james@daa.com.au> + + * gtk/gdk.override: apply Elliot Lee's threading patch. Still + need to fix the remaining threading problems. + 2003-07-25 James Henstridge <james@daa.com.au> * gtk/gtktreeview.override @@ -10,14 +10,3 @@ Things to do for the gtk 2.0 based release new tree models defined in Python. Need to look at how the GtkTreeIter->tree_node lifetime is handled, as it doesn't look like anything is called to let us know that that data should be unrefed. - -- Make python subclasses of GObjects into new types in the GType - system. Should be possible to do from GObject.__class_init__ and a - bit of extra magic. - - Maybe stop adding get_type() class methods, and switch over to - adding __gtype__ class attributes. This is easier when defining new - GObject types (ie. just set an attribute), but may mean calling - get_type() for all classes. Could do some special code so that the - __gtype__ attributes are of a special type that calls the get_type() - macro to convert to an int. diff --git a/gtk/gdk.override b/gtk/gdk.override index 82022fe6..3a1cf7b5 100644 --- a/gtk/gdk.override +++ b/gtk/gdk.override @@ -94,36 +94,46 @@ static GStaticPrivate pythreadstate_key = G_STATIC_PRIVATE_INIT; static GStaticPrivate lock_count_key = G_STATIC_PRIVATE_INIT; static PyInterpreterState *pyinterpstate = NULL; +static gint * +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); + } + + return lock_count; +} + static void pygdk_block_threads (void) { - gint lock_count = GPOINTER_TO_INT(g_static_private_get(&lock_count_key)); + PyThreadState *_save; + gint *lock_count = pygdk_get_lock_count(); - if (lock_count == 0) { - PyThreadState *_save; - - _save = g_static_private_get(&pythreadstate_key); - if (_save == NULL) { - _save = PyThreadState_New(pyinterpstate); - } - Py_BLOCK_THREADS; - } - lock_count++; - g_static_private_set(&lock_count_key, GINT_TO_POINTER(lock_count), NULL); + (*lock_count)++; + if(*lock_count == 1) { + _save = g_static_private_get(&pythreadstate_key); + g_assert(_save); + Py_BLOCK_THREADS; + g_static_private_set(&pythreadstate_key, NULL, NULL); + } } + static void pygdk_unblock_threads (void) { - gint lock_count = GPOINTER_TO_INT(g_static_private_get(&lock_count_key)); - - lock_count--; - if (lock_count == 0) { - PyThreadState *_save; + PyThreadState *_save; + gint *lock_count = pygdk_get_lock_count(); + if(*lock_count == 1) { Py_UNBLOCK_THREADS; g_static_private_set(&pythreadstate_key, _save, NULL); } - g_static_private_set(&lock_count_key, GINT_TO_POINTER(lock_count), NULL); + (*lock_count)--; } #endif @@ -136,7 +146,6 @@ _wrap_gdk_threads_init(PyObject *self) PyEval_InitThreads(); gdk_threads_init(); - g_static_private_set(&lock_count_key, GINT_TO_POINTER(1), NULL); pyinterpstate = PyThreadState_Get()->interp; |