[pygobject] Revert "to-py-struct: don't copy the boxed if we are the sole owner of the wrapper"



commit d371fd77d33c2987cc450bd68ce4ee4835e09bd8
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Thu Feb 8 09:02:37 2018 +0100

    Revert "to-py-struct: don't copy the boxed if we are the sole owner of the wrapper"
    
    This reverts commit a4a68b3c7a4bb64c71e1bdbe52ede109b6bcd0bb.
    
    This was wrong. In the context of a boxed return value we also have only one
    ref but it doesn't get freed after.
    
    We could decide this based on PYGI_CALLING_CONTEXT_IS_FROM_C from the callable cache,
    but let's leave that for now.

 gi/pygi-struct-marshal.c | 11 ++---------
 tests/test_everything.py |  2 --
 2 files changed, 2 insertions(+), 11 deletions(-)
---
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c
index 48ed7445..44797e75 100644
--- a/gi/pygi-struct-marshal.c
+++ b/gi/pygi-struct-marshal.c
@@ -475,15 +475,8 @@ arg_boxed_to_py_cleanup (PyGIInvokeState *state,
                            gpointer         data,
                            gboolean         was_processed)
 {
-    PyGIBoxed *boxed;
-
-    if (arg_cache->transfer == GI_TRANSFER_NOTHING) {
-        boxed = (PyGIBoxed *) cleanup_data;
-        /* If we are the sole owner of the wrapper it will be freed after this
-         * anyway, so no need to copy the wrapped boxed. */
-        if (Py_REFCNT (boxed) > 1)
-            _pygi_boxed_copy_in_place (boxed);
-    }
+    if (arg_cache->transfer == GI_TRANSFER_NOTHING)
+        _pygi_boxed_copy_in_place ((PyGIBoxed *) cleanup_data);
 }
 
 static gboolean
diff --git a/tests/test_everything.py b/tests/test_everything.py
index b7fcb2af..e206954a 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -1129,7 +1129,6 @@ class TestBoxed(unittest.TestCase):
         self.assertEqual(boxed, copy)
         self.assertNotEqual(id(boxed), id(copy))
 
-    @unittest.expectedFailure
     def test_boxed_c_wrapper(self):
         wrapper = Everything.TestBoxedCWrapper()
         obj = wrapper.get()
@@ -1142,7 +1141,6 @@ class TestBoxed(unittest.TestCase):
         del wrapper
         self.assertEqual(obj.refcount, 1)
 
-    @unittest.expectedFailure
     def test_boxed_c_wrapper_copy(self):
         wrapper = Everything.TestBoxedCWrapper()
         wrapper_copy = wrapper.copy()


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