[pygobject] Fix marshalling of arrays of boxed struct values
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix marshalling of arrays of boxed struct values
- Date: Tue, 18 Dec 2012 21:49:10 +0000 (UTC)
commit 9454c01f2b1b82d43eea0f72fe9a28ef50065fc9
Author: Carlos Garnacho <carlos lanedo com>
Date: Tue Dec 18 22:47:09 2012 +0100
Fix marshalling of arrays of boxed struct values
This fixes methods like gtk_selection_set_with_data(). In such cases
data is passed as an array of struct pointers, so it must be converted
to an array of structs.
https://bugzilla.gnome.org/show_bug.cgi?id=656312
Co-Authored-By: Martin Pitt <martinpitt gnome org>
gi/pygi-marshal-from-py.c | 6 ++++++
tests/test_gi.py | 12 ++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index dc14ca5..e842227 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -1009,6 +1009,12 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state,
if (from_py_cleanup)
from_py_cleanup (state, item_arg_cache, item.v_pointer, TRUE);
}
+ } else if (is_boxed && !item_iface_cache->arg_cache.is_pointer) {
+ /* The array elements are not expected to be pointers, but the
+ * elements obtained are boxed pointers themselves, so insert
+ * the pointed to data.
+ */
+ g_array_insert_vals (array_, i, item.v_pointer, 1);
} else {
g_array_insert_val (array_, i, item);
}
diff --git a/tests/test_gi.py b/tests/test_gi.py
index a2664f1..bb90b8a 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -812,6 +812,18 @@ class TestArray(unittest.TestCase):
GIMarshallingTests.array_struct_in([struct1, struct2, struct3])
+ @unittest.skipUnless(hasattr(GIMarshallingTests, 'array_struct_value_in'),
+ 'too old gobject-introspection')
+ def test_array_boxed_struct_value_in(self):
+ struct1 = GIMarshallingTests.BoxedStruct()
+ struct1.long_ = 1
+ struct2 = GIMarshallingTests.BoxedStruct()
+ struct2.long_ = 2
+ struct3 = GIMarshallingTests.BoxedStruct()
+ struct3.long_ = 3
+
+ GIMarshallingTests.array_struct_value_in([struct1, struct2, struct3])
+
def test_array_boxed_struct_take_in(self):
struct1 = GIMarshallingTests.BoxedStruct()
struct1.long_ = 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]