Skip to content

Commit

Permalink
#54: must ref GVariant array argument elements when transfer-full
Browse files Browse the repository at this point in the history
  • Loading branch information
spk121 committed Oct 13, 2019
1 parent 464b5f6 commit 70f5623
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ EVERYTHING_TESTS = \
test/everything/array-zero-terminated-inout.scm \
test/everything/array-gvariant-none-in.scm \
test/everything/array-gvariant-container-in.scm \
test/everything/array-gvariant-full-in.scm \
test/everything/garray-int-none-return.scm \
test/everything/garray-uint64-none-return.scm \
test/everything/garray-utf8-none-return.scm \
Expand Down
5 changes: 4 additions & 1 deletion src/gig_argument.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,10 @@ scm_to_c_native_interface_array(S2C_ARG_DECL)
if (fundamental_item_type == G_TYPE_BOXED) {
((gpointer *)(arg->v_pointer))[i] =
g_memdup(p, gig_meta_real_item_size(&meta->params[0]));
// ((gpointer *)(arg->v_pointer))[i] = p;
}
else if (fundamental_item_type == G_TYPE_VARIANT) {
((gpointer *)(arg->v_pointer))[i] = p;
g_variant_ref(p);
}
else {
((gpointer *)(arg->v_pointer))[i] = p;
Expand Down
16 changes: 16 additions & 0 deletions test/everything/array-gvariant-full-in.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(use-modules (gi)
(test automake-test-lib)
(rnrs bytevectors)
(srfi srfi-43))

(typelib-require ("Marshall" "1.0") ("GLib" "2.0"))

(automake-test
(let ((v1 (variant:new-int32 27))
(v2 (variant:new-string "Hello")))
(let ((x (vector v1 v2)))
(format #t "Input: ~S~%" x)
(let ((y (array-gvariant-full-in x)))
(format #t "Output: ~S~%" x)
(and (= 27 (variant:get-int32 (vector-ref x 0)))
(string=? "Hello" (variant:get-string (vector-ref x 1))))))))

0 comments on commit 70f5623

Please sign in to comment.