[pygobject/pygobject-3-4] Fix array arguments on 32 bit
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [pygobject/pygobject-3-4] Fix array arguments on 32 bit
- Date: Thu, 29 Nov 2012 10:19:41 +0000 (UTC)
commit 82f4d157ac59637475be456c03dcf5db2a502561
Author: Martin Pitt <martinpitt gnome org>
Date:   Thu Nov 29 11:16:26 2012 +0100
    Fix array arguments on 32 bit
    
    In _pygi_argument_from_object() we never put the actual element GType into the
    constructed array. The array contains GIArguments, or bytes in the case of
    passing a string as an array.
    
    This happened to work on 64 bit machines where GIArgument and char* have the
    same size, but not on 32 bit machines (test_gi.TestPropertiesObject.test_strv
    fails there).
 gi/pygi-argument.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index bffe9c4..8ca8772 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1138,7 +1138,11 @@ _pygi_argument_from_object (PyObject   *object,
             is_zero_terminated = g_type_info_is_zero_terminated (type_info);
             item_type_info = g_type_info_get_param_type (type_info, 0);
 
-            item_size = _pygi_g_type_info_size (item_type_info);
+            /* we handle arrays that are really strings specially, see below */
+            if (g_type_info_get_tag (item_type_info) == GI_TYPE_TAG_UINT8)
+               item_size = 1;
+            else
+               item_size = sizeof (GIArgument);
 
             array = g_array_sized_new (is_zero_terminated, FALSE, item_size, length);
             if (array == NULL) {
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]