[pygobject/invoke-rewrite] [gi] fix handling of garrays vs c arrays



commit 329afb6fb1b3c325a6a9de2b6aca91c64d51dd9f
Author: John (J5) Palmieri <johnp redhat com>
Date:   Tue Jan 18 12:31:57 2011 -0500

    [gi] fix handling of garrays vs c arrays

 gi/pygi-argument.c |    9 +++++++--
 gi/pygi-cache.c    |    2 ++
 gi/pygi-cache.h    |    1 +
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index ec299a1..379f58d 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -2635,8 +2635,13 @@ array_success:
         state->in_args[aux_cache->c_arg_index].v_long = length;
     }
 
-    (*arg).v_pointer = array_->data;
-    g_array_free(array_, FALSE);
+    if (sequence_cache->array_type == GI_ARRAY_TYPE_C) {
+        arg->v_pointer = array_->data;
+        g_array_free(array_, FALSE);
+    } else {
+        arg->v_pointer = array_;
+    }
+
     return TRUE;
 }
 
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index c83d25b..d5afc04 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -403,6 +403,8 @@ _arg_cache_new_for_in_array(PyGIFunctionCache *function_cache,
     PyGISequenceCache *seq_cache = _sequence_cache_new_from_type_info(type_info,                                                                      (function_cache->is_method ? 1: 0));
     PyGIArgCache *arg_cache = (PyGIArgCache *)seq_cache;
 
+    seq_cache->array_type = g_type_info_get_array_type(type_info);
+
     if (seq_cache->len_arg_index >= 0) {
         PyGIArgCache *aux_cache = _arg_cache_new();
         aux_cache->aux_type = PYGI_AUX_TYPE_IGNORE;
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index 0c65bd8..853666d 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -82,6 +82,7 @@ typedef struct _PyGISequenceCache
     gint len_arg_index;
     gboolean is_zero_terminated;
     gsize item_size;
+    GIArrayType array_type;
     PyGIArgCache *item_cache;
 } PyGISequenceCache;
 



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