summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2013-05-07 22:50:01 +0200
committerGiovanni Campagna <gcampagna@src.gnome.org>2013-05-23 17:20:26 +0200
commit84a0a8e92b5f8ffa2ae0f0c00e2841bbeb1671ad (patch)
tree7429836f93cce432ed62d191f7092bc9dc6c0d44
parent8734a493b67f5c6997e5c41298a6ba41a5f538cb (diff)
downloadgjs-84a0a8e92b5f8ffa2ae0f0c00e2841bbeb1671ad.tar.gz
Fix regression retriving GTypes from instances
The GValue marshalling code calls get_actual_gtype() on instances. To handle that, we need three levels of recursion: from the instance to the constructor, from the constructor to the GType object and finally from GType object to the actual GType. This regressed in df28a9c070459cc90b0ea0db19bf8e0568ac396a, which was later reverted, but that left the original bug unfixed. https://bugzilla.gnome.org/show_bug.cgi?id=699878
-rw-r--r--gi/gtype.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/gi/gtype.c b/gi/gtype.c
index 850b926a..3d5f5ad3 100644
--- a/gi/gtype.c
+++ b/gi/gtype.c
@@ -145,9 +145,10 @@ gjs_gtype_create_gtype_wrapper (JSContext *context,
return object;
}
-GType
-gjs_gtype_get_actual_gtype (JSContext *context,
- JSObject *object)
+static GType
+_gjs_gtype_get_actual_gtype (JSContext *context,
+ JSObject *object,
+ int recurse)
{
GType gtype = G_TYPE_INVALID;
jsval gtype_val = JSVAL_VOID;
@@ -169,10 +170,25 @@ gjs_gtype_get_actual_gtype (JSContext *context,
goto out;
}
- if (JSVAL_IS_OBJECT(gtype_val))
- gtype = gjs_gtype_get_actual_gtype(context, JSVAL_TO_OBJECT(gtype_val));
+ if (recurse > 0 && JSVAL_IS_OBJECT(gtype_val))
+ gtype = _gjs_gtype_get_actual_gtype(context, JSVAL_TO_OBJECT(gtype_val), recurse - 1);
out:
JS_EndRequest(context);
return gtype;
}
+
+GType
+gjs_gtype_get_actual_gtype (JSContext *context,
+ JSObject *object)
+{
+ /* 2 means: recurse at most three times (including this
+ call).
+ The levels are calculated considering that, in the
+ worst case we need to go from instance to class, from
+ class to GType object and from GType object to
+ GType value.
+ */
+
+ return _gjs_gtype_get_actual_gtype(context, object, 2);
+}