[pygobject/pygobject-3-2] Fix len_arg_index for array arguments
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-3-2] Fix len_arg_index for array arguments
- Date: Wed, 2 May 2012 09:15:22 +0000 (UTC)
commit 99e0f7008671284bf1c176e5f7ef7ee9e37a5a93
Author: Bastian Winkler <buz netbuz org>
Date: Thu Apr 12 20:30:05 2012 +0200
Fix len_arg_index for array arguments
Don't set len_arg_index for arrays without the length annotation given.
This fixes methods like Clutter.Texture.set_from_rgb_data() and
Clutter.Image.set_data()
Skip the test case in the cherrypick, as gobject-introspection do not yet ship
the test API in GNOME 3.4.
https://bugzilla.gnome.org/show_bug.cgi?id=674271
Signed-off-by: Martin Pitt <martinpitt gnome org>
gi/pygi-cache.c | 4 +++-
gi/pygi-marshal-cleanup.c | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 5b107e1..231f6c4 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -161,7 +161,9 @@ _sequence_cache_new (GITypeInfo *type_info,
if (!sc->is_zero_terminated) {
sc->fixed_size = g_type_info_get_array_fixed_size (type_info);
if (sc->fixed_size < 0)
- sc->len_arg_index = g_type_info_get_array_length (type_info) + child_offset;
+ sc->len_arg_index = g_type_info_get_array_length (type_info);
+ if (sc->len_arg_index >= 0)
+ sc->len_arg_index += child_offset;
}
item_type_info = g_type_info_get_param_type (type_info, 0);
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index d580161..0f27ba7 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -279,13 +279,13 @@ _wrap_c_array (PyGIInvokeState *state,
gpointer data)
{
GArray *array_;
- gsize len;
+ gsize len = 0;
if (sequence_cache->fixed_size >= 0) {
len = sequence_cache->fixed_size;
} else if (sequence_cache->is_zero_terminated) {
len = g_strv_length ((gchar **)data);
- } else {
+ } else if (sequence_cache->len_arg_index >= 0) {
GIArgument *len_arg = state->args[sequence_cache->len_arg_index];
len = len_arg->v_long;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]