From 2607f1d4f43019d5739a9391f96f271272039229 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 13 Feb 2008 20:30:17 +0000 Subject: glib-client-gen: special-case G_TYPE_VALUE outputs, fixing a crash when a method returns a variant 20080213203017-53eee-b52ec9ecc53489f71eed9b3e403a2e89a252f615.gz --- tools/glib-client-gen.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tools/glib-client-gen.py') diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py index 590e52046..89af95092 100644 --- a/tools/glib-client-gen.py +++ b/tools/glib-client-gen.py @@ -463,7 +463,13 @@ class Generator(object): name, info, tp_type, elt = arg ctype, gtype, marshaller, pointer = info - self.b(' %s%s;' % (ctype, name)) + # "We handle variants specially; the caller is expected to + # have already allocated storage for them". Thanks, + # dbus-glib... + if gtype == 'G_TYPE_VALUE': + self.b(' GValue *%s = g_new0 (GValue, 1);' % name) + else: + self.b(' %s%s;' % (ctype, name)) self.b('') self.b(' dbus_g_proxy_end_call (proxy, call, &error,') @@ -472,7 +478,10 @@ class Generator(object): name, info, tp_type, elt = arg ctype, gtype, marshaller, pointer = info - self.b(' %s, &%s,' % (gtype, name)) + if gtype == 'G_TYPE_VALUE': + self.b(' %s, %s,' % (gtype, name)) + else: + self.b(' %s, &%s,' % (gtype, name)) self.b(' G_TYPE_INVALID);') @@ -485,6 +494,13 @@ class Generator(object): self.b(' {') self.b(' tp_proxy_pending_call_v0_take_results (user_data, error,') self.b(' NULL);') + + for arg in out_args: + name, info, tp_type, elt = arg + ctype, gtype, marshaller, pointer = info + if gtype == 'G_TYPE_VALUE': + self.b(' g_free (%s);' % name) + self.b(' return;') self.b(' }') self.b('') -- cgit v1.2.3