[pygi] Fix GAsyncReadyCallback



commit 9fc6783406b8263ebd67ceae2730b4e86689b43e
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date:   Fri Apr 30 15:00:52 2010 +0200

    Fix GAsyncReadyCallback
    
    https://bugzilla.gnome.org/show_bug.cgi?id=616236

 gi/pygi-closure.c        |    8 +++++++-
 tests/test_everything.py |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index f452068..2c8d0b3 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -78,7 +78,13 @@ _pygi_closure_handle (ffi_cif *cif,
             case GI_TYPE_TAG_VOID:
                 {
                     if (g_type_info_is_pointer(arg_type)) {
-                        if (PyTuple_SetItem(py_args, n_in_args, closure->user_data) != 0) {
+                        if (closure->user_data == NULL) {
+                            Py_INCREF(Py_None);
+                            if(PyTuple_SetItem(py_args, n_in_args, Py_None) != 0) {
+                                PyErr_Clear();
+                                goto end;
+                            }
+                        } else if (PyTuple_SetItem(py_args, n_in_args, closure->user_data) != 0) {
                             PyErr_Print();
                             goto end;
                         }
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 00b7f95..32ce389 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -76,6 +76,8 @@ class TestNullableArgs(unittest.TestCase):
 
 class TestCallbacks(unittest.TestCase):
     called = False
+    main_loop = gobject.MainLoop()
+
     def testCallback(self):
         TestCallbacks.called = False
         def callback():
@@ -156,3 +158,17 @@ class TestCallbacks(unittest.TestCase):
             self.assertEquals(val, i+1)
             
         self.assertEquals(TestCallbacks.called, 100)
+
+    def testAsyncReadyCallback(self):
+        TestCallbacks.called = False
+        TestCallbacks.main_loop = gobject.MainLoop()
+
+        def callback(obj, result, user_data):
+            TestCallbacks.main_loop.quit()
+            TestCallbacks.called = True
+
+        Everything.test_async_ready_callback(callback)
+
+        TestCallbacks.main_loop.run()
+
+        self.assertTrue(TestCallbacks.called)



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