[gobject-introspection] Fix GVariant handling in regress_test_closure_variant



commit be867f9658b64ee0a93f7730929b421e37b911f6
Author: Martin Pitt <martinpitt gnome org>
Date:   Wed May 2 12:49:25 2012 +0200

    Fix GVariant handling in regress_test_closure_variant
    
    Commit 7c4fbbd6 introduced some low-level g_memdup()ing of the passed GVariant
    in regress_test_closure_variant(). This causes a race condition with GI clients
    like pygobject's test suite, which sometimes fail with
    
      (runtests.py:15653): GLib-CRITICAL **: g_variant_ref_sink: assertion `value->ref_count > 0' failed
    
    Drop the memduping again, and instead make the argument non-const (which is
    true, as the method temporarily increases the refcount).

 tests/scanner/regress.c |    6 ++----
 tests/scanner/regress.h |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 386e10d..2736313 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -221,17 +221,16 @@ regress_test_closure_one_arg (GClosure *closure, int arg)
  * Return value: (transfer full): the return value of @closure
  */
 GVariant*
-regress_test_closure_variant (GClosure *closure, const GVariant* arg)
+regress_test_closure_variant (GClosure *closure, GVariant* arg)
 {
   GValue return_value = {0, };
   GValue arguments[1] = {{0,} };
   GVariant *ret;
-  GVariant *local_arg = (GVariant*)g_memdup(arg, sizeof (GVariant*));
 
   g_value_init (&return_value, G_TYPE_VARIANT);
 
   g_value_init (&arguments[0], G_TYPE_VARIANT);
-  g_value_set_variant (&arguments[0], local_arg);
+  g_value_set_variant (&arguments[0], arg);
 
   g_closure_invoke (closure,
                     &return_value,
@@ -240,7 +239,6 @@ regress_test_closure_variant (GClosure *closure, const GVariant* arg)
 
   ret = g_value_get_variant (&return_value);
 
-  g_free (local_arg);
   g_value_unset (&return_value);
   g_value_unset (&arguments[0]);
 
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index c2a25c1..15b8ce2 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -122,7 +122,7 @@ GPtrArray *regress_test_garray_full_return (void);
 /* closure */
 int regress_test_closure (GClosure *closure);
 int regress_test_closure_one_arg (GClosure *closure, int arg);
-GVariant *regress_test_closure_variant (GClosure *closure, const GVariant* arg);
+GVariant *regress_test_closure_variant (GClosure *closure, GVariant* arg);
 
 /* value */
 int regress_test_int_value_arg(const GValue *v);



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