[seed] Fix handling of GValue structs; fixes segfault
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [seed] Fix handling of GValue structs; fixes segfault
- Date: Sat, 6 Feb 2010 02:12:24 +0000 (UTC)
commit dbf7423f196043966b90fa4aad6dc50f51647bf5
Author: Alan Knowles <alan akbkhome com>
Date: Fri Feb 5 20:57:24 2010 -0500
Fix handling of GValue structs; fixes segfault
Fixes gtk_tree_model_get_value calls eventually segfaulting
Fixes BGO#608015
libseed/seed-engine.c | 11 ++++++++---
libseed/seed-structs.c | 24 ++++++++++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 1f0e7ae..8b668e7 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -125,9 +125,14 @@ seed_struct_constructor_invoked (JSContextRef ctx,
{
if (!JSValueIsObject (ctx, arguments[0]))
{
- seed_make_exception (ctx, exception, "ArgumentError",
- "Constructor expects object as argument");
- return (JSObjectRef) JSValueMakeNull (ctx);
+
+ // new GObject.GValue() can accept anything as a argument...
+ GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info);
+ if (!g_type_is_a (gtype, G_TYPE_VALUE)) {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "Constructor expects object as argument");
+ return (JSObjectRef) JSValueMakeNull (ctx);
+ }
}
parameters = (JSObjectRef) arguments[0];
}
diff --git a/libseed/seed-structs.c b/libseed/seed-structs.c
index 5abeabe..a443eda 100644
--- a/libseed/seed-structs.c
+++ b/libseed/seed-structs.c
@@ -311,6 +311,15 @@ seed_struct_get_property (JSContextRef context,
"with name %s \n",
g_base_info_get_name (priv->info), cproperty_name);
+ // for a gvalue, it has a special property 'value' (read-only)
+ GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) priv->info);
+
+ if (g_type_is_a (gtype, G_TYPE_VALUE) && !g_strcmp0 (cproperty_name, "value"))
+ {
+ return seed_value_from_gvalue ( context, ( GValue *) priv->pointer, exception);
+
+ }
+
field =
seed_struct_find_field ((GIStructInfo *) priv->info, cproperty_name);
@@ -696,6 +705,21 @@ seed_construct_struct_type_with_parameters (JSContextRef ctx,
if (type == GI_INFO_TYPE_STRUCT)
{
+ GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info);
+ if (g_type_is_a (gtype, G_TYPE_VALUE))
+ {
+ GValue *gval = g_slice_alloc0 (sizeof (GValue));
+ if (!parameters)
+ {
+ seed_make_exception (ctx, exception, "ArgumentError", "Missing Type in GValue constructor");
+ return (JSObjectRef) JSValueMakeNull (ctx);
+ }
+ SEED_NOTE (CONSTRUCTION, "Created a GValue struct");
+ seed_gvalue_from_seed_value (ctx, parameters , 0, gval, exception);
+ ret = seed_make_struct (ctx, (gpointer)gval, info);
+ return ret;
+ }
+
size = g_struct_info_get_size ((GIStructInfo *) info);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]