From 90aaf720cefcaed82196ea275b3a513315877300 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Tue, 3 Aug 2004 14:11:46 +0000 Subject: Clean up most functions here to have only one return path. * gtk/pygtktreemodel.c: Clean up most functions here to have only one return path. * gobject/pygobject.c (pygobject_emit): Protect g_value_unset by UNBLOCK/BLOCK_THREADS since it might call pygobject_free which will result in a deadlock. * gobject/gobjectmodule.c (pyg_thread_init): New function, move thread initalization stuff in here. * All over the place: Kill pyg_block/unblock_threads and use PyGILState and Py_BEGIN/END_ALLOW_THREADS. unblock [code] block calls are replaced by Py_BEGIN/END and block [code] unblock calls are replaced by PyGILState. --- gobject/pygpointer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gobject/pygpointer.c') diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c index b7e3cfc..4173e7c 100644 --- a/gobject/pygpointer.c +++ b/gobject/pygpointer.c @@ -185,16 +185,16 @@ pyg_register_pointer(PyObject *dict, const gchar *class_name, PyObject * pyg_pointer_new(GType pointer_type, gpointer pointer) { + PyGILState_STATE state; PyGPointer *self; PyTypeObject *tp; - g_return_val_if_fail(pointer_type != 0, NULL); - pyg_block_threads(); + state = PyGILState_Ensure(); if (!pointer) { Py_INCREF(Py_None); - pyg_unblock_threads(); + PyGILState_Release(state); return Py_None; } @@ -203,7 +203,7 @@ pyg_pointer_new(GType pointer_type, gpointer pointer) tp = (PyTypeObject *)&PyGPointer_Type; /* fallback */ self = PyObject_NEW(PyGPointer, tp); - pyg_unblock_threads(); + PyGILState_Release(state); if (self == NULL) return NULL; -- cgit