pygobject r927 - in trunk: . glib gobject



Author: johan
Date: Wed Aug  6 08:28:12 2008
New Revision: 927
URL: http://svn.gnome.org/viewvc/pygobject?rev=927&view=rev

Log:
2008-08-06  Johan Dahlin  <johan gnome org>

    * glib/pyglib.c (pyglib_enable_threads):
    * gobject/gobjectmodule.c (pyg_threads_init),
    (pygobject_enable_threads):
    Add a pygobject_enable_threads wrapper around pyglib_threads_enable
    and return 0/-1 which existing gobject based applications expect.



Modified:
   trunk/ChangeLog
   trunk/glib/pyglib.c
   trunk/gobject/gobjectmodule.c

Modified: trunk/glib/pyglib.c
==============================================================================
--- trunk/glib/pyglib.c	(original)
+++ trunk/glib/pyglib.c	Wed Aug  6 08:28:12 2008
@@ -121,25 +121,31 @@
     PyGILState_Release(state);
 }
 
+/**
+ * pyglib_enable_threads:
+ *
+ * Returns: TRUE if threading is enabled, FALSE otherwise.
+ *
+ */
 #ifdef DISABLE_THREADING
-int
+gboolean
 pyglib_enable_threads(void)
 {
     PyErr_SetString(PyExc_RuntimeError,
 		    "pyglib threading disabled at compile time");
-    return -1;
+    return FALSE;
 }
 #else
 /* Enable threading; note that the GIL must be held by the current
  * thread when this function is called
  */
-int
+gboolean
 pyglib_enable_threads(void)
 {
-    g_return_val_if_fail (_PyGLib_API != NULL, -1);
+    g_return_val_if_fail (_PyGLib_API != NULL, FALSE);
 
     if (_PyGLib_API->threads_enabled)
-	return 0;
+	return TRUE;
   
     PyEval_InitThreads();
     if (!g_threads_got_initialized)
@@ -148,7 +154,7 @@
     _PyGLib_API->threads_enabled = TRUE;
     pyglib_thread_state_tls_key = PyThread_create_key();
     
-    return 0;
+    return TRUE;
 }
 #endif
 

Modified: trunk/gobject/gobjectmodule.c
==============================================================================
--- trunk/gobject/gobjectmodule.c	(original)
+++ trunk/gobject/gobjectmodule.c	Wed Aug  6 08:28:12 2008
@@ -1788,13 +1788,22 @@
 static PyObject *
 pyg_threads_init (PyObject *unused, PyObject *args, PyObject *kwargs)
 {
-    if (pyglib_enable_threads())
+    if (!pyglib_enable_threads())
         return NULL;
     
     Py_INCREF(Py_None);
     return Py_None;
 }
 
+/* Only for backwards compatibility */
+int
+pygobject_enable_threads(void)
+{
+    if (!pyglib_enable_threads())
+	return -1;
+    return 0;
+}
+
 static PyObject *
 pyg_signal_accumulator_true_handled(PyObject *unused, PyObject *args)
 {
@@ -2452,7 +2461,7 @@
   pyg_flags_from_gtype,
 
   FALSE, /* threads_enabled */
-  pyglib_enable_threads,
+  pygobject_enable_threads,
   pygobject_gil_state_ensure,
   pygobject_gil_state_release,
   pyg_register_class_init,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]