summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-02-26 21:44:08 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2014-04-11 01:35:52 +0200
commit45bbf5b2a07f6764437f8c876baf5fae864e2976 (patch)
tree1ebcd78bd6c314014e7d41c91e2d75158db9ca28
parent945fd018ebd5e30a5b91bcc034a3e8e39c673da7 (diff)
downloadgjs-45bbf5b2a07f6764437f8c876baf5fae864e2976.tar.gz
ParamSpec: fix argument marshalling
We need to treat GParamSpec and derived classes as gjs_param, otherwise we fallback on gjs_fundamental and crash. https://bugzilla.gnome.org/show_bug.cgi?id=725282
-rw-r--r--gi/arg.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/gi/arg.cpp b/gi/arg.cpp
index aa11570a..ba86c23f 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1493,6 +1493,15 @@ gjs_value_to_g_argument(JSContext *context,
arg->v_pointer = NULL;
wrong = TRUE;
}
+ } else if (g_type_is_a(gtype, G_TYPE_PARAM)) {
+ if (gjs_typecheck_param(context, JSVAL_TO_OBJECT(value), gtype, JS_TRUE)) {
+ arg->v_pointer = gjs_g_param_from_param(context, JSVAL_TO_OBJECT(value));
+ if (transfer != GI_TRANSFER_NOTHING)
+ g_param_spec_ref(G_PARAM_SPEC(arg->v_pointer));
+ } else {
+ arg->v_pointer = NULL;
+ wrong = TRUE;
+ }
} else if (g_type_is_a(gtype, G_TYPE_BOXED)) {
if (g_type_is_a(gtype, G_TYPE_CLOSURE)) {
arg->v_pointer = gjs_closure_new_marshaled(context,
@@ -2537,7 +2546,6 @@ gjs_value_from_g_argument (JSContext *context,
GIBaseInfo* interface_info;
GIInfoType interface_type;
GType gtype;
- gboolean gtype_is_object, gtype_is_interface;
interface_info = g_type_info_get_interface(type_info);
g_assert(interface_info != NULL);
@@ -2876,7 +2884,6 @@ gjs_g_arg_release_internal(JSContext *context,
GIBaseInfo* interface_info;
GIInfoType interface_type;
GType gtype;
- gboolean gtype_is_object, gtype_is_interface;
interface_info = g_type_info_get_interface(type_info);
g_assert(interface_info != NULL);
@@ -2905,16 +2912,12 @@ gjs_g_arg_release_internal(JSContext *context,
* don't have to worry about it.
*/
- gtype_is_object = g_type_is_a(gtype, G_TYPE_OBJECT);
- gtype_is_interface = g_type_is_a(gtype, G_TYPE_INTERFACE);
- if (gtype_is_object || gtype_is_interface) {
- if (gtype_is_object) {
- if (transfer != TRANSFER_IN_NOTHING)
- g_object_unref(G_OBJECT(arg->v_pointer));
- } else {
- if (transfer != TRANSFER_IN_NOTHING)
- gjs_fundamental_unref(context, arg->v_pointer);
- }
+ if (g_type_is_a(gtype, G_TYPE_OBJECT)) {
+ if (transfer != TRANSFER_IN_NOTHING)
+ g_object_unref(G_OBJECT(arg->v_pointer));
+ } else if (g_type_is_a(gtype, G_TYPE_PARAM)) {
+ if (transfer != TRANSFER_IN_NOTHING)
+ g_param_spec_unref(G_PARAM_SPEC(arg->v_pointer));
} else if (g_type_is_a(gtype, G_TYPE_CLOSURE)) {
g_closure_unref((GClosure *) arg->v_pointer);
} else if (g_type_is_a(gtype, G_TYPE_VALUE)) {